Fix pgr_bellmanFord neg-edges empty check#3072
Fix pgr_bellmanFord neg-edges empty check#3072sakirr05 wants to merge 1 commit intopgRouting:developfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 WalkthroughThe no-edges detection condition in the Bellman-Ford negative driver was modified. The logic now treats the case as "no edges" only when both the standard edge list and negative edge list are simultaneously empty, affecting behavior when no edges exist. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fix wrong empty-check in Bellman-Ford neg-edges driver
The neg-edges driver was returning "No edges found" whenever the main
edges_sqlhad any rows. The bug is in the condition that decides when to treat the graph as empty.What was wrong
In
bellman_ford_neg_driver.cppwe had:edges.size()is asize_tandneg_edges.empty()is abool(0 or 1). So we're doing integer + bool. For example with 3 positive edges and 2 negative edges we get3 + 0 = 3(truthy), so we always hit this early return when there are any positive edges. The only time we didn't was whenedgeswas empty andneg_edges.empty()was true (0 + 1 = 1), i.e. both empty.Fix
We only want to return "No edges found" when both edge sets are empty:
Example (before vs after)
Before the fix, a call with both positive and negative edges returns no rows:
What's in this PR
src/bellman_ford/bellman_ford_neg_driver.cpp(line 119).Summary by CodeRabbit