我可以从改进我们的查询中得到一些帮助吗?
所以这个想法是我们有许多连接的子图,每个顶点都有一个唯一的id。现在我们知道了一些 id,我们想在一个查询中获取所有连接的顶点。
例如,我们有 a -> b <- c -> d 和 e -> f <- g。现在输入是{b, e},我们想要的结果是{a, b, c, d, e, f, g}。因为,{a, c, d} 连接到 b 而 {f, g} 连接到 e。
目前我正在使用一个非常愚蠢的查询,例如
g.V("b").emit().repeat(both().simplePath()).aggregate("connected")
.V("e").emit().repeat(both().simplePath()).aggregate("connected")
.select("connected").unfold().dedup()
有时可能会起作用,但是当(如果)所有顶点已经相互连接时,我会遇到 MemoryLimitExceededException
答案 0 :(得分:0)
Gremlin Recipes 包含一个连接组件的方法,但可能不适合非常大的图。请看[1]。
[1] https://tinkerpop.apache.org/docs/current/recipes/#connected-components