cancel
Showing results forΒ
Search instead forΒ
Did you mean:Β

## How can I retrieve non virtual relationships from the result of A*?

Node

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

0 REPLIES 0
Nodes 2022

NODES 2022, Neo4j Online Education Summit

OnΒ November 16 and 17 for 24 hours across all timezones, youβll learn about best practices for beginners and experts alike.

Neo4j Resources