fix(query): correct frontier trimming in shortest path#9599
fix(query): correct frontier trimming in shortest path#9599Schwarf wants to merge 3 commits intodgraph-io:mainfrom
Conversation
ddde7e8 to
ae5a482
Compare
|
Hi @themavik, From what I see, both PRs fix the same underlying issue (removing an arbitrary element instead of the highest-cost one), but they differ slightly in eviction policy:
My understanding is that push-then-trim better preserves the intended frontier under a size cap, because it effectively keeps the best In addition, this PR includes a regression test ( That said, I’m happy to align with whichever eviction policy you prefer, or close this PR and contribute the test to #9607 if that’s the direction you’d like to take. |
Description
Fix incorrect frontier trimming in shortest path queries when
maxfrontiersizeis set.
Previously, the code used
pq.Pop()to trim the priority queue. This removesthe last element of the heap rather than the highest-cost
element, which can discard valid low-cost candidates and lead to incorrect
shortest-path results.
The fix replaces slice-based removal with
heap.Removeof the maximum-costelement.
Applied in both:
shortestPathrunKShortestPathsA regression unit test has been added to ensure the highest-cost element is
removed when trimming.
Fixes #9577