我正在尝试计算边缘中间性。该查询在 gremlin 控制台上运行良好,但在 gremlin-python 中不起作用。
g.V().as_("v").
repeat(identity().as_("src").
bothE().as_("e").
bothV().as_("v").
where(neq("src")).
simplePath()).
emit().
filter(project("x","y","z").
by(select(first, "v")).
by(select(last, "v")).
by(select("v").count(local)).as_("triple").
coalesce(select("x","y").as_("a").
select("triples").unfold().as_("t").
select("x","y").
where(eq("a")).
select("t"),
store("triples")).
select("z").as_("length").
select("triple").
select("z").
where(eq("length"))).
select('e').
unfold().
groupCount()
错误是:TypeError: unhashable type: 'dict'
如果我将其更改为 vertex-betweenness,那么它就可以正常工作。我觉得的问题是如何在 python 中检索边缘,它是一张地图。当我进行分组计数时,它还会创建一个映射,其中键作为边缘,值作为计数。在 python 中,键本身不能是映射,因此会引发此错误。
如何解决这个问题?还请解释如何select(all, 'e')
在 gremlin-python 中使用。