Hey all,
I want to traverse using a tricky condition.
Condition:
If in a traversal path, two vertex separated by a distance of1 have same vertex type then that path should not be considered.
OR
While traversing if a vertex is encountered whose path-2 vertex is of the same type, stop the traversal there.
I do not want to apply a filter conditions once all the paths are traversed. I want to perform this filtering while the traversal is happening.
Sample Graph:
l1=graph.addVertex("type","l","id","l1")
p1=graph.addVertex("type","p","id","p1")
l2=graph.addVertex("type","l","id","l2")
v1=graph.addVertex("type","v","id","v1")
l3=graph.addVertex("type","l","id","l3")
l1.addEdge("edge",p1)
p1.addEdge("edge",l2)
p1.addEdge("edge",v1)
v1.addEdge("edge",l3)
Output:
If start node is l1 then output is (p1,v1,v3)
If start node is p1 then output is (l1,l2,v1,l3)
If start node is l2 then output is (p1,v1,l3)
If start node is v1 then output is (p1,l1,l2,l3)
If start node is l3 then output is (v1,p1,l1,l2)
______________________________________________________________________________________________________________________
I am stuck at trying to figure out the syntax for the n-2 element in the path. Moreover can I have an if else condition inside my traversal?
Something like
g.V().repeat( obtain path-2 if exists && if type of path-2 vertex != current vertex.path then both())
Any insights on how I can perform this kind of traversal, greatly appreciated.
Thanks and Regards,
Antriksh Shah