目标:找出两种节点类型之间的最小和最大关系长度。
示例:以下是节点类型' T'
的虚拟连接(APLHA) - >(布拉沃)
(布拉沃) - >(查理)
因此到达两个节点的最小跳数是1(即Aplha直接链接到Charlie),到达两个节点的最大跳数是2(即(Aplha) - (Beta) - (Charlie))。
我的查询就像:
g.V().hasLabel("Process").as("from", "to")
.repeat(both().as("to").dedup("from", "to")).emit(hasLabel("Process"))
.hasLabel("Process")
// I was unable to get only min and max, using both min and max did not work so I made a work-around (.as("len").max().dedup())
.select(all, "to").count(local).as("count").math("count - 1").as("len").dedup()
与使用NEO4J APOC as in this solution
相比,这非常慢有没有办法实现这种操作是一种更快的方式?
我不能使用的解决方案:
限制关系长度:我必须在n级使用它,所以不能将它限制在3或4级。