0

If i have a pre-run route from the shortestPath which is returned as a list of vertex, how can i then re-run that on a graph with the same set of vertices, to return the edges which it has used.

i.e. PATH = (V(1), V(2), V(3), V(4), V(5), V(6)), how would the command look to replay that path on a new graph with the same vertices, returning the edges, which contain different properties.

So to confirm i need to input this explicit Path to return the edges?

docker dev
  • 91
  • 3
  • 10
  • Is there some reason you don't return the edges on the first query that gets you the shortest path? – stephen mallette Apr 13 '20 at 10:55
  • Yes for some reason the logic is that the routing is done on this graph and then we run the same path with a different graph containing the same vertices, but with different edges to return an ordered list of these new edges used, which give us a different set of information? There is some logic involved at some point. So i really need to transfer a Path of vertices from one graph and run it from vertex to vertex until the destination reached and return the edges. Is that possible to do? – docker dev Apr 13 '20 at 12:40

1 Answers1

1

If I knew my path was [v[1],v[4],v[3] I suppose I would just build something like this:

gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V(1).out().hasId(4).out().hasId(3).path()
==>[v[1],v[4],v[3]]

Since your path may be of variable length I suppose I would just cycle through it and dynamically construct the traversal adding a out().hasId() for each vertex in the path.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • That makes complete sense however i do: gremlin> g.V('L00-041').out().hasId('L00-042').out().hasId('L00-043').out().hasId('L00-031').path() gremlin> I just get no output... – docker dev Apr 14 '20 at 12:41
  • i'm not sure what could be wrong. did you try to see if ` g.V('L00-041')` returns anything? if it does then try, `g.V('L00-041').out()`. if that works then `g.V('L00-041').out().hasId('L00-042')` and so on until you find where your data is being filtered away – stephen mallette Apr 14 '20 at 14:47