当前,只需一次遍历,我就可以做到:
Edge edge = g.E().Next();
var inv = edge.InV;
var outv = edge.OutV;
var id = edge.Id;
这使我可以获得边缘的ID,以及边缘之间的顶点的ID。或者,我可以这样做:
IDictionary<object, object> dict = g.E().ValueMap<object, object>(true).Next();
var id = dict[T.id]
var edgeProp = dict["$edgePropertyName"];
这允许我获取属性和ID,但不能获取边缘的ID。有没有办法在单个遍历中同时获得顶点和属性?
答案 0 :(得分:3)
好的,只需使用project()
:
gremlin> g.E().
......1> project('id','properties','out','in').
......2> by(id).
......3> by(valueMap()).
......4> by(outV().id()).
......5> by(inV().id())
==>[id:7,properties:[weight:0.5],out:1,in:2]
==>[id:8,properties:[weight:1.0],out:1,in:4]
==>[id:9,properties:[weight:0.4],out:1,in:3]
==>[id:10,properties:[weight:1.0],out:4,in:5]
==>[id:11,properties:[weight:0.4],out:4,in:3]
==>[id:12,properties:[weight:0.2],out:6,in:3]
答案 1 :(得分:0)
将接受的答案翻译成C#:
var result = g.E()
.Project<object>("id", "properties", "out", "in")
.By(__.Id())
.By(__.ValueMap<string, object>())
.By(__.OutV().Id())
.By(__.InV().Id())
.Next();