我不想再遍历同一个顶点,但我在CosmosDB Gremlin API中无法使用otherV。有没有其他的替代方法?
你没有举例说明你的用法,但有时我看到人们这样做。
gremlin> g.V(1).bothE().otherV()
==>v[3]
==>v[2]
==>v[4]
这其实是公正的。
gremlin> g.V(1).both()
==>v[3]
==>v[2]
==>v[4]
后者更便宜。你只需要 otherV()
在你需要过滤边缘的场景下。
gremlin> g.V(1).bothE().has('weight',gt(0.4)).otherV()
==>v[2]
==>v[4]
如果你有这种更合法的情况下 otherV()
需要的话,你可以用步骤标签和 where()
喜欢。
gremlin> g.V(1).as('a').bothE().has('weight',gt(0.4)).union(inV(),outV()).where(neq('a'))
==>v[2]
==>v[4]