Gremlin Tinkerpop使用“范围步长”选择按顶点分组的邻居

Gremlin Tinkerpop使用“范围步长”选择按顶点分组的邻居,gremlin,tinkerpop,tinkerpop3,gremlin-server,tinkergraph,Gremlin,Tinkerpop,Tinkerpop3,Gremlin Server,Tinkergraph,我想选择所有l标记的顶点以及它们的t标记的顶点,这些顶点按其相邻顶点分组。我还想对邻居的长度施加限制。 对于ex For Neighbor limit=2,应输出如下内容 [ {"l1",[t1,t2]}, {"l2",[t3]}, {"l3",[]} ] [ {"l1",[t1]}, {"l2",[t3]}, {"l3",[]} ] 对于ex For Neighbor l

我想选择所有
l
标记的顶点以及它们的
t
标记的顶点,这些顶点按其相邻顶点分组。我还想对邻居的长度施加限制。 对于ex For Neighbor limit=2,应输出如下内容

[
{"l1",[t1,t2]},
{"l2",[t3]},
{"l3",[]}
]
[
{"l1",[t1]},
{"l2",[t3]},
{"l3",[]}
]
对于ex For Neighbor limit=1,应输出如下内容

[
{"l1",[t1,t2]},
{"l2",[t3]},
{"l3",[]}
]
[
{"l1",[t1]},
{"l2",[t3]},
{"l3",[]}
]
灰色链接

我认为
group()

gremlin> g.V().has('label','l').
......1>   group().
......2>     by('name').
......3>     by(out().limit(2).values('name').fold())
==>[l1:[t1,t2],l2:[t3]]
gremlin> g.V().has('label','l').
......1>   group().
......2>     by('name').
......3>     by(out().limit(1).values('name').fold())
==>[l1:[t1],l2:[t3]]
请注意,第二个
by()
调制器是对您分组的收集项目进行的缩减操作。在那里,您可以根据需要进一步操作该集合。为了演示,我稍微修改了您的数据:

g.addV('Vertex').as('1').property(single, 'name', 'l1').property(single, 'label', 'l').
  addV('Vertex').as('2').property(single, 'name', 'l2').property(single, 'label', 'l').
  addV('Vertex').as('3').property(single, 'name', 'l3').property(single, 'label', 'l').
  addV('Tag').as('4').property(single, 'name', 't1').property(single, 'label', 't').
  addV('Tag').as('5').property(single, 'name', 't2').property(single, 'label', 't').
  addV('Tag').as('6').property(single, 'name', 't3').property(single, 'label', 't').
  addV('Tag').as('7').property(single, 'name', 't4').property(single, 'label', 't').
  addE('connected').from('1').to('4').
  addE('connected').from('1').to('5').
  addE('connected').from('2').to('6').
  addE('next').from('2').to('7')
在下面的例子中,我刚刚使用
union()
创建了两个列表,每个“类型”一个:


当然,您可以使用other将其转换为其他形式。

有没有一种方法可以选择多种类型的邻居。例如:``g.V().has('label','l')。组()。用(‘名字’)称呼。by(out(“oneType”).limit(1).values('name').fold()。by(out(“secondType”).limit(1).values('name').fold())```