[Neo4j] Gremlin syntax for multiple paths in one call

Marko Rodriguez okrammarko at gmail.com
Tue Oct 4 17:19:50 CEST 2011


Hey,

> If I want to get the following 
> 
> g.V(0).out('Friends')
> 
> and 
> 
> g.V(0).in('Likes') 


This is the world of split and merge. The syntax for this is not the sexiest, but as it stands:

	g.v(0)._.copySplit(_().out('Friends'), _().in('Likes')).fairMerge

copySplit will take what comes into it and copy it to its internal pipes (in this case, 2 internal pipes). Then fairMerge will, in a round robin fashion, merge the output of the two internal pipes into a single pipe. Thus, split the pipeline, then merge it back into a single pipeline.

For example, over the play TinkerPop graph:

gremlin> g = TinkerGraphFactory.createTinkerGraph()
==>tinkergraph[vertices:6 edges:6]
gremlin> g.v(1)._.copySplit(_().out('created'),_().out('knows')).fairMerge
==>v[3]
==>v[2]
==>v[4]

We haven't developed split/merge much. If you have any ideas for syntax, that'd be great.

NOTE: If they were both out, then you can simply do:  g.v(0).out('friends','likes')

Good luck,
Marko.

http://markorodriguez.com


More information about the User mailing list