重新运行Tinkerpop图中的现有路线 [英] Re-running an existing route in a Tinkerpop Graph
问题描述
如果我有一条从shortestPath出发的预先运行路线,该路线作为顶点列表返回,那么我该如何在具有相同顶点集的图形上重新运行该路线,以返回其已使用的边.
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.
即PATH =(V(1),V(2),V(3),V(4),V(5),V(6)),该命令将如何在相同的新图上重播该路径顶点,返回包含不同属性的边.
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?
推荐答案
如果我知道我的路径是[v[1],v[4],v[3]
,我想我会建立这样的东西:
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]]
由于您的路径可能具有可变长度,所以我想我会循环遍历并动态构造遍历,为路径中的每个顶点添加一个out().hasId()
.
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.
这篇关于重新运行Tinkerpop图中的现有路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!