Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gremlin 如何限制分支的遍历次数_Gremlin_Tinkerpop3 - Fatal编程技术网

Gremlin 如何限制分支的遍历次数

Gremlin 如何限制分支的遍历次数,gremlin,tinkerpop3,Gremlin,Tinkerpop3,从玩具图开始,我可以通过查找已“创建”出边的边来找到哪些顶点是创建者: gremlin> graph = TinkerFactory.createModern() ==>tinkergraph[vertices:6 edges:6] graph.traversal().V().as('a').out('created').select('a').values('name') ==>marko ==>josh ==>josh ==>peter 我可以通过重复数

从玩具图开始,我可以通过查找已“创建”出边的边来找到哪些顶点是创建者:

gremlin> graph = TinkerFactory.createModern()
==>tinkergraph[vertices:6 edges:6]
graph.traversal().V().as('a').out('created').select('a').values('name')
==>marko
==>josh
==>josh
==>peter
我可以通过重复数据消除步骤过滤掉重复数据

gremlin> graph.traversal().V().as('a').out('created').select('a').dedup().values('name')
==>marko
==>josh
==>peter
…但这只会改变输出,而不会改变小精灵所遵循的路径。如果创建者可以是超级节点,我想告诉查询在找到其第一个“已创建”边后输出“a”,然后停止遍历当前“a”的out步骤并继续下一个“a”。这能做到吗

此语法具有所需的输出。他们的行为符合我的意愿吗

graph.traversal().V().where(out('created').count().is(gt(0))).values('name')
graph.traversal().V().where(out('created').limit(1).count().is(gt(0))).values('name')
有更好的食谱吗

编辑:我刚刚在where文档(示例2)中找到一个示例,显示存在一个被评估为真实的链接(可能没有正确的措辞):


有一个关于星图问题的警告,我认为它不适用于这里,因为,我猜,只有一个步骤可以测试一个分支?

最后一个例子就是要走的路

g.V().where(out('created')).values('name')
战略将为您优化这一点,并将其转化为:

g.V().where(outE('created')).values('name')
另外,
。其中(outE('created')
不会遍历所有的外边缘,它就像一个
.hasNext()
,因此没有超级节点问题

g.V().where(outE('created')).values('name')