Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-30-2021 01:36 AM
In Neo4j 3.5.* when using algo.kShortestPaths.stream() for calculating a number of shortest paths using weights between two nodes, there was the option to set the direction by using {direction:'OUT'}.
Currently I am using Neo4j 4.2.4 and calling gds.beta.shortestPath.yens.stream(), but the algorithm returns paths in all directions, so it's ignoring the directed relationships between nodes. I want to the algorithm to use only (outgoing) directions from the startnode to the endnode.
Is there a possibility to use the direction of the paths in Yen's K-shortest paths algorithm? Or should I switch to another algorithm with this functionality?
Old cypher query:
MATCH (start:GENE{name:'<startnode_name>'}), (end:GENE{name:'<endnode_name>'})
CALL algo.kShortestPaths.stream(start, end, 10, 'weight' ,{direction:'OUT'})
YIELD index, nodeIds, costs
RETURN [node in algo.getNodesById(nodeIds) | node.name] AS places,costs,reduce(acc = 0.0, cost in costs | acc + cost) AS totalCost
New cypher query:
MATCH (source:GENE {name: '<startnode_name>'}), (target:GENE {name: '<endnode_name>'})
CALL gds.beta.shortestPath.yens.stream('full_graph', { sourceNode: id(source), targetNode: id(target), k: 10, relationshipWeightProperty: 'weight'})
YIELD index, sourceNode, targetNode, totalCost, nodeIds, costs
RETURN index, gds.util.asNod
05-03-2021 01:15 AM
All the sessions of the conference are now available online