I am basically trying to search all the connected Vertices for a node type, the Cypher query version gives me the expected result, but the Gremlin version is not giving me the intended result. Any thing that I am doing incorrectly??
Visual Representation of my data
Cyher Query to fetch all the connections
MATCH p=shortestPath((n:Process)-[*]-(m:Process))
WHERE n <> m
RETURN ID(n), n, ID(m), m, length(p)
Gremlin version
gremlin> g.V().hasLabel('Process')
.repeat(both().simplePath())
.until(hasLabel('Process'))
.path().by('title')
==>[Cash Processing,Accounting]
==>[Cash Processing,Sales]
==>[Sales,Marketing]
==>[Sales,Cash Processing]
==>[Marketing,Accounting]
==>[Marketing,Sales]
==>[Accounting,Cash Processing]
==>[Accounting,Marketing]
Any idea why Gremlin is not catching the 'Cash Processing'->'Sales'->'Marketing' connection???
I got a feeling something needs a change in that until() function, but cant figure out what
You don't talk about the labels of your vertices, but to me, it seems like the Sales
vertex already fulfills the until(HasLabel('Process'))
stop condition.
The correct translation of your Cypher query would be something more like this:
g.V().hasLabel('Process').as('n').
repeat(both().simplePath()).
emit(hasLabel('Process')).as('m').
dedup('n','m').
path().count(local).as('len').
select('m','n','len')