Hi,
I found out that I can use shortest path and avoid loops by applying apoc.coll.duplicates on path nodes list.
What if I want to consider duplicates those nodes that share the same value for a given attribute (e.g. ALTER_NAME).
Would be possible to apply a DISTINCT on the nodes values and doing something like
WHERE apoc.coll.duplicates(NODES(path).ALTER_NAME) = ?
MATCH (source:POINT {NAME: 'A'}), (target:POINT {NAME: 'B'})
CALL gds.shortestPath.dijkstra.stream('mygraph', {
sourceNode: source,
targetNode: target,
relationshipWeightProperty: 'miles'
})
YIELD index, sourceNode, targetNode, totalCost, nodeIds, costs, path
WHERE apoc.coll.duplicates(NODES(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