用Gremlin选择不同的节点?

时间:2013-06-14 23:26:41

标签: gremlin

如果有多条边连接同一对节点,both将返回重复的节点:

gremlin> v2 = g.addVertex(null,['x':5,'y':7])
==>v[360004]
gremlin> v3 = g.addVertex(null, ['x':2,'y':3])
==>v[360008]
gremlin> g.addEdge(v2,v3,'test')
==>e[6IeZ-1vEw-2F0LaTPQQu][360004-test->360008]
gremlin> g.addEdge(v2,v3,'test 2')
==>e[6If7-1vEw-2F0LaTPQQC][360004-test 2->360008]
gremlin> v2.both.map
==>{y=3, x=2}
==>{y=3, x=2}

如何确保我找回一个独特的节点列表?

1 个答案:

答案 0 :(得分:4)

dedup简化了这一过程,并在Gremlin docs中进行了解释。对于上面的例子:

gremlin> v2.both.dedup.map
==>{y=3, x=2}