In order to visualize our path, we will first write the results into the graph. This is not mandatory, but will slightly simplify the following queries.
Instead of using gds.alpha.shortestPath.stream, we are going to call the gds.alpha.shortestPath.write procedure. The parameters are similar, but the returned values are completely different:
MATCH (A:Node {name: "A"})
MATCH (E:Node {name: "E"})
CALL gds.alpha.shortestPath.write("graph_weighted", {
startNode: A,
endNode: E,
relationshipWeightProperty: "weight"
}
) YIELD totalCost
RETURN totalCost
This writes the result of the shortest path algorithm into an sssp property on the nodes belonging to the shortest path.
The name of the property used to write the result to the original graph can be configured by adding a writeProperty key to the configuration map.
If we want to retrieve that path, including the relationships, we have to find the relationship...