Re-running an existing route in a Tinkerpop Graph

不羁的心 提交于 2020-04-18 05:47:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!