Graph Gremlin-按成本排序最短加权路径输出
我尝试使用Gremlin从Amazon-Neptune图中获得最短加权路径,如TinkerPop配方中所示-Graph Gremlin-按成本排序最短加权路径输出,graph,gremlin,traversal,shortest-path,amazon-neptune,Graph,Gremlin,Traversal,Shortest Path,Amazon Neptune,我尝试使用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))
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')
是的。谢谢