Hello everybody,
I have this simple graph:
And I perform single source shortest path algorithm on it to obtain all the path cost, for all the nodes, from one node. I run this following query (starting from node 'T' for the example) :
MATCH (n{name: 'T'})
CALL gds.alpha.shortestPath.deltaStepping.stream({
nodeProjection: ['DIGITAL_SUBSYSTEM','PHYSICAL_SUBSYSTEM'],
relationshipProjection: {link: {type: '*', properties: 'exposure', orientation: 'NATURAL'}},
startNode: n, relationshipWeightProperty: 'exposure', delta: 1.0})
YIELD nodeId, distance
RETURN gds.util.asNode(nodeId).name AS node , distance AS cost ORDER BY cost
I obtain the following table:
I'm pretty satisfied with the results but I would like to remove from my query the nodes linked with a REVERSE
relationship orientation (with a cost value "infinity" in my table) .
Maybe I should use nodeQuery
and relationshipQuery
instead of nodeProjection
and relationshipProjection
?
Like this example I have found in Neo4j shortest path algorithm documentation (not single source):
MATCH (start:Loc {name: 'A'}), (end:Loc {name: 'F'})
CALL gds.alpha.shortestPath.write({
nodeQuery:'MATCH(n:Loc) WHERE NOT n.name = "c" RETURN id(n) AS id',
relationshipQuery:'MATCH(n:Loc)-[r:ROAD]->(m:Loc) RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
startNode: start,
endNode: end,
relationshipWeightProperty: 'weight',
writeProperty: 'sssp'
})
YIELD nodeCount, totalCost
RETURN nodeCount,totalCost
Other question, I specified orientation: NATURAL
in my initial query, why it doesn't remove the node "P3" that is linked to "PLC2" with a REVERSE
relationship ?
Thanks for your help,
Nicolas.