0

This is the code i'm executing:

g.v(452).outE('friend', 'like').outV()

The return 52 nodes ... i want to form them in categories by edge type, something like:

[ {friend: [v2,v3,v4...]}, {'like': [v5,v7,v9...]} ]

4

1 回答 1

1

Using the toy graph from the Gremlin terminal for example purposes :

gremlin> g = TinkerGraphFactory.createTinkerGraph()
==>tinkergraph[vertices:6 edges:6]

I added an extra edge called 'friends' to make the data a bit more interesting (where there would be multiple edges between two vertices):

gremlin> g.addEdge(g.v(1), g.v(2), 'friends')
==>e[0][1-friends->2]
gremlin> g.v(1).outE('knows','created','friends')
==>e[7][1-knows->2]
==>e[8][1-knows->4]
==>e[9][1-created->3]
==>e[0][1-friends->2]

From there you could do something like:

gremlin> g.v(1).outE('knows','created','friends').groupBy{it.label}{it.inV.next()}.cap
==>{knows=[v[2], v[4]], friends=[v[2]], created=[v[3]]}
于 2012-11-19T21:03:55.687 回答