The method produces a number of outputs. These are shown below for the example I captured from the documentation.
CALL gds.shortestPath.dijkstra.stream(
graphName: String,
configuration: Map
)
YIELD
index: Integer,
sourceNode: Integer,
targetNode: Integer,
totalCost: Float,
nodeIds: List of Integer,
costs: List of Float,
path: Path
You can get the relationship information from the path, using 'relationships(path)'. This returns a list of relationships. Each relationships contains its: id, startNode, endNode, properties, and type. You can extract them as follows: id(path), startNode(path), endNode(path), properties(path), and type(path), respectively.
I took the example from the documentation and altered it to return the list of relationships along the resulting path. I returned the relationship information individually. You can alter it to return what you need.
It turns out the path relationships returned are not the actual relationships; they are virtual relationships with a type equal to the path, i.e. PATH_0. You can see this if you look at the path relationships, as they have negative identifiers.
Anyway, I added stuff to the query to take the start and end nodes of each path relationship and get the true relationship between the nodes, so its type can be returned.
Try this:
match(n:Person {name:"Mary"}) , (p:Ride {type:"Ring Toss"})
with ID(n) as st, ID(p) as en
CALL gds.shortestPath.dijkstra.stream(
'mygraph',{
sourceNode: st,
targetNode: en}
)
yield path
with relationships(path) as p
unwind range(0,size(p)-1) as segment
with segment, startNode(p[segment]) as startNode, endNode(p[segment]) as endNode
with segment, startNode, endNode, id(startNode) as start_id, id(endNode) as end_id
match(n where id(n) = start_id)
match(m where id(m) = end_id)
match(n)-[r]-(m)
return segment as segment, start_id as startNodeId, type(r) as type, end_id as endNodeId