graph-data-science icon indicating copy to clipboard operation
graph-data-science copied to clipboard

gds.shortestPath.dijkstra.stream not return relationship type

Open johnfercher opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

I have a graph with multiple edge types and I need to retrieve the shortest path having the edge type of each one. I'm trying to execute the follow query:

MATCH (source:City {id: 'natal'}), (target:City {id: 'pelotas'})
CALL gds.shortestPath.dijkstra.stream('projection', {
    sourceNode: source,
    targetNodes: target,
    relationshipWeightProperty: 'distance_km'
})
YIELD index, sourceNode, targetNode, totalCost, nodeIds, costs, path
RETURN
    index,
    gds.util.asNode(sourceNode).name AS sourceNodeName,
    gds.util.asNode(targetNode).name AS targetNodeName,
    totalCost,
    [nodeId IN nodeIds | gds.util.asNode(nodeId).name] AS nodeNames,
    costs,
    nodes(path) as path
ORDER BY index

It works, but I don´t know how to retrieve the relationship types. Executing this query in localhost:7474 if return edge types, but the text don't.

Screenshot from 2024-09-15 23-38-59

I didn't find a way to retrieve this info using the documentation. This is my projection.

MATCH (a:City)-[r]->(b:City)
RETURN gds.graph.project(
  'projection',
  a,
  b,
  { 
	relationshipProperties: r { .distance_km },
    relationshipType: type(r)
  }
)

Describe the solution you would like

I would like a way to retrieve the relationship type as I retrieve the costs. Example, by adding a type after path.

MATCH (source:City {id: 'natal'}), (target:City {id: 'pelotas'})
CALL gds.shortestPath.dijkstra.stream('projection', {
    sourceNode: source,
    targetNodes: target,
    relationshipWeightProperty: 'distance_km'
})
YIELD index, sourceNode, targetNode, totalCost, nodeIds, costs, path, relationshipType
RETURN
    index,
    gds.util.asNode(sourceNode).name AS sourceNodeName,
    gds.util.asNode(targetNode).name AS targetNodeName,
    totalCost,
    [nodeId IN nodeIds | gds.util.asNode(nodeId).name] AS nodeNames,
    costs,
    nodes(path) as path,
    relationshipType
ORDER BY index

Describe alternatives you have considered

Additional context

johnfercher avatar Sep 16 '24 02:09 johnfercher

@johnfercher thank you for creating this issue, we have put it in our backlog, however there is no concrete timeline on when it will be available in GDS.

vnickolov avatar Sep 16 '24 14:09 vnickolov