求教:如何一次性获取与给定顶点有关联的所有顶点?
问题描述: 我定位到一个顶点,想通过一条gremlin语句获取所有与它有关联的顶点个数,如何实现?
我想实现的语句的意思是:
g.V(‘1***9’).repeat(both()).until(both(). <the other> .count().is(0)).simplePath()
但会导致死循环,hugeGraph Server 的%CPU 直接超过100%。求教如何完善 until()里的内容
@baibingzhi 请尝试下:
g.V(xx).repeat(both().simplePath()).until(__.not(both().simplePath()).or().loops().is(10)).path()
可以的,谢谢老师
@javeme @Linary 出现一个问题,上面的gremlin在起始顶点有边的时候是可以的,但是当起始顶点没有任何边的时候,用上面的gremlin会导致连自身也查不出来,求教如何解决?
@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()
@baibingzhi 请尝试下:
g.V(xx).repeat(both().simplePath()).until(__.not(both().simplePath()).or().loops().is(10)).path()
@javeme g.V("#").repeat(both()).times(2).path() 请问这两种写法有啥区别吗?
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