paths = {
const paths = [];
const P = shortest_junctions(graph, tree);
for (const code of P.costs.keys()) {
const cost = P.costs.get(code),
junction = P.junctions.get(code),
path = junction.slice();
path.reverse();
while (tree.predecessor[path[0]] > -1)
path.unshift(tree.predecessor[path[0]]);
path.reverse();
while (tree.predecessor[path[0]] > -1)
path.unshift(tree.predecessor[path[0]]);
paths.push({ cost, junction, path });
}
return paths;
}