Gremlin.Net 在一次遍历中获取边 Id、InV、OutV 和属性

Sam*_*arr 3 .net c# gremlin tinkerpop

目前,通过一次遍历,我可以执行以下操作:

Edge edge = g.E().Next();
var inv = edge.InV;
var outv = edge.OutV;
var id = edge.Id;
Run Code Online (Sandbox Code Playgroud)

这使我能够获取边的 id,以及边所经过的顶点的 id。或者,我可以这样做:

IDictionary<object, object> dict = g.E().ValueMap<object, object>(true).Next();
var id = dict[T.id]
var edgeProp = dict["$edgePropertyName"];
Run Code Online (Sandbox Code Playgroud)

这允许我获取属性和 id,但不能获取边缘的 id。有没有办法在一次遍历中同时获取顶点和属性?

ste*_*tte 5

当然,只需使用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]
Run Code Online (Sandbox Code Playgroud)