Repository navigation
30 dijkstra - #133
Open
eriknw wants to merge 1 commit into
Open
30 dijkstra#133eriknw wants to merge 1 commit into
eriknw wants to merge 1 commit into
Conversation
Serve it with the batched Bellman-Ford kernel, which now takes a cutoff. With no negative or NaN weight, the length NetworkX's Dijkstra gives a node is the least sum over the walks to it, which is what min-plus finds, here in the weights' own type, float32 included. Each source's dict holds the source, at the integer 0, and then the other nodes by increasing length, equal lengths in id order. NetworkX orders equal lengths by its heap, which is arbitrary. Negative and NaN weights are left to NetworkX, since its lengths and its "Contradictory paths" error there follow its walk. A weight function, a graph class that reports another adjacency, and a cutoff that does not compare as a float does are declined. Integer weights whose sums could overflow raise when called, not at the first item. The tests compare targets and integer lengths exactly and float lengths within rounding, and check that every length is a shortest path's: no edge shortens one, and a tight edge leads into each.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 32-float-path-lengths #133 +/- ##
=========================================================
+ Coverage 92.92% 93.18% +0.26%
=========================================================
Files 182 183 +1
Lines 11286 11741 +455
Branches 1279 1341 +62
=========================================================
+ Hits 10487 10941 +454
Misses 546 546
- Partials 253 254 +1 🚀 New features to boost your workflow:
|
eriknw
force-pushed
the
32-float-path-lengths
branch
from
December 2, 2026 20:40
faf0d71 to
28445c9
Compare
This was referenced Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
all_pairs_dijkstra_path_length. For each source it yields the same targets as NetworkX with the same lengths: integer lengths exactly, float lengths within rounding. Each dict is in the backend's own order, not NetworkX's.backend_priority._adj(such as_AntiGraph), and a cutoff that is not an int below 2**53, a float, or a NumPy integer or float64. Python compares those types with a length differently than a matrix of lengths does.gnm_random_graph(3000, 15000), converted, with every item read into a dict, as the median of three interleaved rounds that each took the best of three. Unit weights take 0.64 s here against NetworkX's 9.7 s; random floats 1.23 s against 14.9 s; weights of 0, 1 or 2 0.75 s against 12.4 s; float32 weights 1.21 s against 17.2 s. The version first pushed here, which replayed NetworkX's order, took 4.3, 1.22, 10.5 and 13.8 s. The conversion adds 0.02 s. Ordering each dict by length is 0.1 to 0.4 s of these times: in node order they would be 0.37, 0.84, 0.64 and 0.78 s. On the first 300 sources of each graph, the lengths equal NetworkX's exactly.dijkstra_path_length,single_source_dijkstra_path_lengthandmulti_source_dijkstra_path_length. With the conversion counted, the same kernel loses on a random graph of 1e5 nodes, and on grids of 1e5 and 1e6 nodes both cold and warm. A grid needs a round per step of its diameter.bidirectional_dijkstraand the path names are not served either.OverflowError; with 26 overflow fallback #126 it becomesIntegerOverflowError, and NetworkX answers such weights itself underbackend_priority, as it does forall_pairs_bellman_ford_path_length.ego_graphwith adistanceon such a graph.Stacked on #129.