我尝试使用Gremlin从Amazon Neptune图获得最短的加权路径,如TinkerPop食谱中所示 -
gremlin> g.V(1).repeat(outE().inV().simplePath()).until(hasId(5)).
path().as('p').
map(unfold().coalesce(values('weight'),
constant(0.0)).sum()).as('cost').
select('cost','p')
但是,我需要输出将按计算的成本(最低成本作为第一个输出)排序,而不是按路径中的节点数排序。
我在查询中尝试了一些order().by(..)
组合但没有成功
这能满足您的需求吗?
g.V(1).repeat(outE().inV().simplePath()).until(hasId(5)).
path().as('p').
map(unfold().coalesce(values('weight'),
constant(0.0)).sum()).as('cost').
order().by(select('cost')).
select('cost','p')