Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-23-2022 09:01 AM
Hello,
I have a pretty simple graph for transportation:
1 type of nodes connected by either one of the 2 relationships I have (A and B).
I need to find the shortest path between 2 nodes, I use A* and I created a graph using `CALL gds.graph.project`.
What I need is to limit the number of hops to a number N, but this number should be counted only if the relationship type is A, I can have as many B as I want.
When I run the query, I use the function `relationships(path)` to retrieve the relationships, but it returns always virtual relationships, so it is not possible to retrieve the real type.
Here is how I have defined the graph
CALL gds.graph.project("myGraph",
{
Node:{
properties:["latitude","longitude"]
}
},
{
A:{
type: 'A',
properties:["distanceKm"],
orientation:'NATURAL'
},
B:{
type: 'B',
properties:["distanceKm"],
orientation:'NATURAL'
}
}
)
And how I call the A*:
CALL gds.shortestPath.astar.stream('myGraph', {
sourceNode: source,
targetNode: target,
latitudeProperty: 'latitude',
longitudeProperty: 'longitude',
relationshipWeightProperty: 'distanceKm'
})
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
How can I retrieve the real relationships types and their properties? What is the best way to filter by the relationship type?
Thanks
All the sessions of the conference are now available online