Hello,
I am looking for an efficient way to calculate the shortest route between two vertices on a graph existing of approx. 5000 vertices and 15000 edges, taking into account the sum of the edge lengths (property 'dist' on each edge).
A well-known algorithm for this problem is Dijkstra's algorithm (
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm). This algorithm picks the unvisited vertex with the lowest distance, calculates the distance through it to each unvisited neighbor, and updates the neighbor's distance if smaller. Has such an algorithm ever been implemented in Gremlin, or is it something that could easily be constructed?
g.V("687").repeat(outE().inV().simplePath()).until(hasId("1343")).
path().as('p').
map(unfold().coalesce(values('dist'),
constant(0.0)).sum()).as('cost').
order().by(select('cost')).
select('cost','p')
Does someone know a better way to do this?
Thanks in advance for your help!