Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-07-2022 01:49 AM
query1: match p=shortestpath((a:A)-[e:E*1..3]->(b:B)) return p,size(e) AS steps
query2: match p=allshortestpaths((a:A)-[e:E*1..3]->(b:B)) return p,size(e) AS steps
I did some tests and they all got the same result, my expectation is that if there are multiple shortest paths between two points then only one is returned, obviously I misunderstood.
So, what topology should I use to test the difference between these two queries, and does neo4j support finding any shortest path?
Solved! Go to Solution.
03-14-2022 06:49 AM
Hi @czp, keep in mind that if you have multiple input records/rows, you will get a separate result from shortestPath()
for each row, since Cypher operations operate per row.
With shortestPath()
, your output rows should be <= the number of input rows (since rows, where no path exists, will be weeded out, and there should be at most one result per row).
With allShortestPaths()
, your output rows may be greater than your input rows, depending on how many paths have the same length per input row.
03-14-2022 06:49 AM
Hi @czp, keep in mind that if you have multiple input records/rows, you will get a separate result from shortestPath()
for each row, since Cypher operations operate per row.
With shortestPath()
, your output rows should be <= the number of input rows (since rows, where no path exists, will be weeded out, and there should be at most one result per row).
With allShortestPaths()
, your output rows may be greater than your input rows, depending on how many paths have the same length per input row.
All the sessions of the conference are now available online