incubator-hugegraph icon indicating copy to clipboard operation
incubator-hugegraph copied to clipboard

求教:如何一次性获取与给定顶点有关联的所有顶点?

Open baibingzhi opened this issue 8 years ago • 6 comments

问题描述: 我定位到一个顶点,想通过一条gremlin语句获取所有与它有关联的顶点个数,如何实现?

我想实现的语句的意思是:
g.V(‘1***9’).repeat(both()).until(both(). <the other> .count().is(0)).simplePath()
但会导致死循环,hugeGraph Server 的%CPU 直接超过100%。求教如何完善 until()里的内容

baibingzhi avatar Oct 30 '18 09:10 baibingzhi

@baibingzhi 请尝试下: g.V(xx).repeat(both().simplePath()).until(__.not(both().simplePath()).or().loops().is(10)).path()

javeme avatar Oct 30 '18 13:10 javeme

可以的,谢谢老师

baibingzhi avatar Oct 31 '18 02:10 baibingzhi

@javeme @Linary 出现一个问题,上面的gremlin在起始顶点有边的时候是可以的,但是当起始顶点没有任何边的时候,用上面的gremlin会导致连自身也查不出来,求教如何解决?

baibingzhi avatar Mar 15 '19 08:03 baibingzhi

@baibingzhi repeat-until是do-while,对于独立的顶点在第一步both()时就没有结果了,因此不会出现在结果中。如果需要独立节点,可以:

g.V(xx).emit(loops().is(0)).until(__.not(both().simplePath()).or().loops().is(10)).repeat(both().simplePath()).path()

zhoney avatar Mar 18 '19 04:03 zhoney

@baibingzhi 请尝试下: g.V(xx).repeat(both().simplePath()).until(__.not(both().simplePath()).or().loops().is(10)).path()

@javeme g.V("#").repeat(both()).times(2).path() 请问这两种写法有啥区别吗?

Ghosttttt avatar Apr 01 '19 09:04 Ghosttttt

Due to the lack of activity, the current issue is marked as stale and will be closed after 20 days, any update will remove the stale label

github-actions[bot] avatar Jan 23 '22 21:01 github-actions[bot]