Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-02-2022 04:31 AM
Why do different modes of the same algorithm produce different results?
match (source:Node1 {start_marker:1})
call gds.allShortestPaths.dijkstra.stream('orient_undirected__agr_single', {sourceNode: source})
yield index, sourceNode, targetNode, nodeIds, path
return index, sourceNode, targetNode, nodeIds, path
match (source:Node1 {start_marker:1})
call gds.allShortestPaths.dijkstra.write('orient_undirected__agr_single',{
sourceNode: source,
writeRelationshipType: 'PATH',
writeNodeIds: true,
})
YIELD relationshipsWritten
RETURN relationshipsWritten
match (n) return n
Solved! Go to Solution.
03-02-2022 04:53 AM
This method as per documentation creates a relationship between start node and all the target nodes with cost and node id's in between start and target.
From that perspective this graph is correct.
Having multiple relationships between same nodes does not add any perspective to shortest path.
03-02-2022 04:53 AM
This method as per documentation creates a relationship between start node and all the target nodes with cost and node id's in between start and target.
From that perspective this graph is correct.
Having multiple relationships between same nodes does not add any perspective to shortest path.
03-02-2022 06:13 AM
Hi anthapu,
thank you for the info!
Do you think you could suggest which algorithm would be the best to keep all nodes on each path?
03-04-2022 06:23 AM
I guess I am not understanding your issue correctly. The stream option does give you all the paths. Do you need to create a set of relationships from START and END node?
Won't it add too many relationships to already existing data set?
What the write is doing is telling you between node1 and node2 if PATH relationship exists, what other nodes are in between to reach to node2 in a shortest path.
03-08-2022 03:41 AM
Hi @anthapu,
The idea was to reduce all those paths PATH_*
to a single PATH
.
From that graph:
I wanted to reach the following state:
(don't take into consideration different labels, only what matters here are the relationships)
I thought I can achieve that by simply removing those paths PATH_*
.
Then, I've learnt that they are virtual objects, and I cannot work on them directly. I need to convert them first to the real objects.
So I run the algorithm in the write mode believing it will store all PATH_*
, but the result was different.
I've found another algorithm, but I think I don't quite understand why STREAM shows all nodes in the path, and WRITE just returns the path and additionally creates self-relationship tho the starting node.
All the sessions of the conference are now available online