Cast tree() into a subgraph()

31 views
Skip to first unread message

Olav Laudy

unread,
Jan 19, 2018, 7:07:55 PM1/19/18
to Gremlin-users
Hi,


I have a graph that contains cyclic structures. In order to simplify the viewing of the structure, (in other software), I used to create a tree out of it and view the tree instead.

In Gremlin, I make use of subgraph() to display a small portion of my larger graph.

I can use tree() to create a tree structure, however, I don't see how I can make a subgraph after I created a tree.



This is my query so far:

g.V().has('name','W').as('source') \
                          .repeat(__.inE().as('in') \
                          .where('in',neq('source')).by(outV().id()).by(id()) \
                          .subgraph('subGraph').outV().as('out')) \
                          .times(3).cap('subGraph')

as you can see, I prevent nodes coming back to the first level ('source') by my where statement. If I want to generalize this, I'd have to keep track of all the nodes that I passed so far and use a 'within' statement for the lookup.

My question is how to collect the list of growing nodes over the repeat and use them in the within statement. 


Thanks!


Olav

Daniel Kuppitz

unread,
Jan 21, 2018, 1:35:32 PM1/21/18
to gremli...@googlegroups.com
Aggregate everything (all edges) along the path and use the collection to filter previously seen edges.

g.V().has('name','W').
  repeat(inE().where(without('x')).aggregate('x').
         subgraph('s').outV()).
    times(3).
  cap('s')

Cheers,
Daniel


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/5421f24b-140d-431f-93e5-6e7559ee1135%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages