问题
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?
回答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.
来源:https://stackoverflow.com/questions/61177108/re-running-an-existing-route-in-a-tinkerpop-graph