Example

Let's review a graph query example posted on gremlin-users mailing list:

Let the input vertices be v2, v3 and v4, and now find those vertices, that have the most outgoing edges to the aforementioned vertices:

gremlin> g = TinkerFactory.createClassic()
==>tinkergraph[vertices:6 edges:6]
gremlin> input = g.V(2,3,4).toList()
==>v[2]
==>v[3]
==>v[4]
gremlin> sm = g.of().inject(input).unfold().in().groupCount().next().sort { -it.getValue() }
==>v[1]=3
==>v[4]=1
==>v[6]=1
gremlin> m = sm.iterator().next().getValue()
==>3
gremlin> result = sm.grep { it.getValue() == m }*.getKey()
==>v[1]

What do you think about the example? Does this look familiar? If you didn't read the description of the query, would you have guessed what it's going to return?

Let's chop it piece by piece and learn the API by the example.

results matching ""

    No results matching ""