Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.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
图遍历&;使用OrientDB使用Gremlin进行过滤_Orientdb_Gremlin - Fatal编程技术网

图遍历&;使用OrientDB使用Gremlin进行过滤

图遍历&;使用OrientDB使用Gremlin进行过滤,orientdb,gremlin,Orientdb,Gremlin,给定上述顶点,我希望查询组顶点,其中组没有任何可选顶点,选定属性为true 因此,结果应该只返回b组 Group[code=a]->Choice[selected=true] Group[code=a]->Choice[selected=false] Group[code=a]->Choice[selected=false] Group[code=b]->Choice[selected=false] Group[code=b]->Choice[selected=fa

给定上述顶点,我希望查询组顶点,其中组没有任何可选顶点,选定属性为true

因此,结果应该只返回b组

Group[code=a]->Choice[selected=true]
Group[code=a]->Choice[selected=false]
Group[code=a]->Choice[selected=false]
Group[code=b]->Choice[selected=false]
Group[code=b]->Choice[selected=false]
Group[code=c]->Choice[selected=false]
Group[code=c]->Choice[selected=true]

非常感谢您的帮助。

这是您的图表-在询问有关Gremlin的问题时,以以下方式提供示例数据总是很有帮助的:

Group[code=b]
获得所需答案的一种方法是进行如下遍历:

graph = TinkerGraph.open()
g = graph.traversal()
g.addV('group').property('code','a').as('a').
  addV('group').property('code','b').as('b').
  addV('group').property('code','c').as('c').
  addV('choice').property('selected',true).
  addE('link').from('a').
  addV('choice').property('selected',false).
  addE('link').from('a').
  addV('choice').property('selected',false).
  addE('link').from('a').
  addV('choice').property('selected',false).
  addE('link').from('b').
  addV('choice').property('selected',false).
  addE('link').from('b').
  addV('choice').property('selected',false).
  addE('link').from('c').
  addV('choice').property('selected',true).
  addE('link').from('c').iterate()
以上答案适用于TinkerPop 3.x。在Tinkerpop2.x中,模式是相同的。你基本上会做:

gremlin> g.V().hasLabel('group').
......1>   where(__.not(out('link').has('selected',true))).
......2>   values('code')
==>b

这是您的图表-在询问有关Gremlin的问题时,以以下方式提供示例数据总是很有帮助的:

Group[code=b]
获得所需答案的一种方法是进行如下遍历:

graph = TinkerGraph.open()
g = graph.traversal()
g.addV('group').property('code','a').as('a').
  addV('group').property('code','b').as('b').
  addV('group').property('code','c').as('c').
  addV('choice').property('selected',true).
  addE('link').from('a').
  addV('choice').property('selected',false).
  addE('link').from('a').
  addV('choice').property('selected',false).
  addE('link').from('a').
  addV('choice').property('selected',false).
  addE('link').from('b').
  addV('choice').property('selected',false).
  addE('link').from('b').
  addV('choice').property('selected',false).
  addE('link').from('c').
  addV('choice').property('selected',true).
  addE('link').from('c').iterate()
以上答案适用于TinkerPop 3.x。在Tinkerpop2.x中,模式是相同的。你基本上会做:

gremlin> g.V().hasLabel('group').
......1>   where(__.not(out('link').has('selected',true))).
......2>   values('code')
==>b

谢谢虽然这在Tinkerpop 3中可行,但我一直在寻找使用Tinkerpop 2x的解决方案,因为OrientDB社区版本仍然支持较旧的Tinkerpop规范。我对2.x的了解不可靠,但模式大致相同。将我的答案更新为包含2.x,并对3.x答案进行了额外改进。现在,遍历在到达第一个
true
时立即停止,而不是迭代所有相邻顶点,寻找并可能找到多个true。非常感谢Stephen!谢谢虽然这在Tinkerpop 3中可行,但我一直在寻找使用Tinkerpop 2x的解决方案,因为OrientDB社区版本仍然支持较旧的Tinkerpop规范。我对2.x的了解不可靠,但模式大致相同。将我的答案更新为包含2.x,并对3.x答案进行了额外改进。现在,遍历在到达第一个
true
时立即停止,而不是迭代所有相邻顶点,寻找并可能找到多个true。非常感谢Stephen!