Cypher allShortestPaths 只是 return 一条路径?
Cypher allShortestPaths just return one path?
背景说明:
我有如下图表:
我想找到节点 A 和节点 F 之间的所有路径(比如我可以通过多少种方式从 A 到达 F),然后我的 Cypher 如下所示:
MATCH (start:kg:test), (end:kg:test), p = allShortestPaths((start)-[*..8]-(end))
where start.value = 'A' and end.value = 'F'
RETURN start, end, p
- 如我所料,此查询将 return 整个图,但它只是 returns A->F(return 使用
shortestPath
函数),如下所示:
问题
- 为什么该查询不会 return 图中的所有不同路径?
- 我是否滥用了
allShortestPaths
功能?
- 如何获取从节点 A 到节点 F 的所有路径?
谢谢
shortestPath()
returns 节点之间的单个最短路径(如果有多个相同大小它只是 returns 它找到的第一个)。
如果 shortestPath()
可以 return 编辑多条路径(它们都具有相同的大小),那么 allShortesPaths()
将 return 它们。
如果你只想找到两个节点之间的所有可能路径(路径的长度无关紧要,你根本不关心最短路径),那么你不需要使用任何一个这些功能。
MATCH p=(start:kg:test)-[*..8]-(end:kg:test)
where start.value = 'A' and end.value = 'F'
RETURN start, end, p
背景说明:
我有如下图表:
我想找到节点 A 和节点 F 之间的所有路径(比如我可以通过多少种方式从 A 到达 F),然后我的 Cypher 如下所示:
MATCH (start:kg:test), (end:kg:test), p = allShortestPaths((start)-[*..8]-(end)) where start.value = 'A' and end.value = 'F' RETURN start, end, p
- 如我所料,此查询将 return 整个图,但它只是 returns A->F(return 使用
shortestPath
函数),如下所示:
问题
- 为什么该查询不会 return 图中的所有不同路径?
- 我是否滥用了
allShortestPaths
功能? - 如何获取从节点 A 到节点 F 的所有路径?
谢谢
shortestPath()
returns 节点之间的单个最短路径(如果有多个相同大小它只是 returns 它找到的第一个)。
如果 shortestPath()
可以 return 编辑多条路径(它们都具有相同的大小),那么 allShortesPaths()
将 return 它们。
如果你只想找到两个节点之间的所有可能路径(路径的长度无关紧要,你根本不关心最短路径),那么你不需要使用任何一个这些功能。
MATCH p=(start:kg:test)-[*..8]-(end:kg:test)
where start.value = 'A' and end.value = 'F'
RETURN start, end, p