gremlin shortestPath() with(ShortestPath.edges, Direction.OUT)

gremlin shortestPath() with(ShortestPath.edges, Direction.OUT)

与(ShortestPath.edges, Direction.OUT) 这个选项是什么? 工作还好吗? 有什么不同 ? 我无法理解解释。 https://tinkerpop.apache.org/docs/current/reference/#shortestpath-step

我想更具体地了解一下。 我试试这个。 它比默认 Direction.BOTH.

这两个选项对结果有影响吗?什么时候?

我希望这会让您更轻松:(Direction.Both 与 Direction.IN + Direction.OUT 相同)

基于此图表:https://tinkerpop.apache.org/docs/current/reference/#graph-computing

g.V('4').shortestPath().with(ShortestPath.edges,Direction.OUT).with(ShortestPath.maxDistance,1).with(ShortestPath.includeEdges,true)

==>[v[4]]

==>[v[4],e[11][4-创建->3],v[3]]

==>[v[4],e[10][4-创建->5],v[5]]

g.V('4').shortestPath().with(ShortestPath.edges,Direction.IN).with(ShortestPath.maxDistance,1).with(ShortestPath.includeEdges,true)

==>[v[4],e[8][1-知道->4],v[1]]

==>[v[4]]

和DIRECTION.BOTH将是入边和出边

g.V('4').shortestPath().with(ShortestPath.edges,Direction.BOTH).with(ShortestPath.maxDistance,1).with(ShortestPath.includeEdges,true)

==>[v[4],e[8][1-知道->4],v[1]]

==>[v[4],e[10][4-创建->5],v[5]]

==>[v[4]]

==>[v[4],e[11][4-创建->3],v[3]]

你也应该看到默认值,我将 maxdistance 设置为 1 以使其更容易