tinkerpop3:使用 gremlin 计算所有节点对之间的边数

Alb*_*rto 1 gremlin tinkerpop3

我有一个多重图,我有兴趣计算连接每对节点的边数;此外,我需要为每对节点获取某个属性的最大值。

不幸的是,在我看来,我们只能使用.group().by(...)一个属性,而我需要按inV和分组outV。在 Cypher 中,我会写一些类似的东西

MATCH (e0: Employee)-[fb: R]-> (e1: Employee)
WITH e0, e1, count(*) AS frequency, min(fb.value) AS min_val
RETURN e0, e1, frequency, min_val
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

干杯!

Dan*_*itz 5

在 Gremlin 用户邮件列表上回答,但为了关闭圈子,这里再次遍历:

gremlin> g.V().as("e0").outE("e").as("e").inV().as("e1").select("e0","e","e1").
gremlin>       group().by(select("e0","e1").by("name")).
gremlin>               by(fold().match(__.as("x").count(local).as("freq"),
gremlin>                               __.as("x").unfold().select("e").by("value").max().as("max")).select("freq","max")
gremlin>               ).next()
==>{e0=c, e1=d}={freq=1, max=9}
==>{e0=b, e1=d}={freq=1, max=9}
==>{e0=f, e1=h}={freq=1, max=9}
==>{e0=e, e1=h}={freq=1, max=9}
==>{e0=a, e1=b}={freq=2, max=10000}
==>{e0=b, e1=c}={freq=4, max=4}
==>{e0=e, e1=f}={freq=1, max=9}
==>{e0=f, e1=g}={freq=1, max=9}
==>{e0=a, e1=c}={freq=1, max=9}
Run Code Online (Sandbox Code Playgroud)