Skip to content

gds.shortestPath.dijkstra.stream not return relationship type #329

Open
@johnfercher

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA suggestion for a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions