Repository navigation
Conversation
Each is a reduction over shortest-path lengths found for a batch of sources at a time, the walk harmonic_centrality and closeness_centrality use: the greatest length in a source's row is its eccentricity, and the other four take the least or the greatest of those. Memory is bounded by the batch rather than by the number of node pairs. With `usebounds` on an undirected graph whose lengths are integers, the four walk from as few nodes as the Takes and Kosters bounds allow, in batches that double, so a long thin graph costs a few batches rather than a walk from every node. Elsewhere every node is walked from; the message a disconnected graph raises follows `usebounds` either way, as NetworkX's does. Integer weights raise OverflowError where n times the heaviest absolute weight reaches 2**62, as in the bellman_ford names, since a length, or the sum of two that the bounds take, could pass 2**63. A precomputed `sp` and the null graph, whose answer differs between NetworkX releases, are left to NetworkX. A given `e` is read as NetworkX reads it.
Both sum over the batches of shortest-path lengths that eccentricity reads: harmonic_diameter the reciprocals of the nonzero lengths (the sum harmonic_centrality takes per node), average_shortest_path_length the lengths themselves, once it has checked that every node reaches every node, which NetworkX checks first. The lengths are found and summed in floats, as both answers are: integer lengths, and their sums, can pass 2**63. average_shortest_path_length answers `method` None, "unweighted", "dijkstra" and "bellman-ford". The Floyd-Warshall methods, which answer a negative cycle with a number where this walk raises, and any other value are left to NetworkX, as is harmonic_diameter's `sp`.
eriknw
force-pushed
the
13-distance-measures
branch
from
December 2, 2026 07:11
97968df to
2700338
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 12-components #112 +/- ##
=================================================
+ Coverage 90.52% 91.14% +0.62%
=================================================
Files 156 159 +3
Lines 8460 9053 +593
Branches 1065 1112 +47
=================================================
+ Hits 7658 8251 +593
+ Misses 557 553 -4
- Partials 245 249 +4 🚀 New features to boost your workflow:
|
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 the distance measures, computed as reductions over batches of shortest-path lengths.
eccentricity,diameter,radius,center,periphery(withuseboundson an undirected graph with integer lengths they walk from as few nodes as the bounds allow)harmonic_diameter,average_shortest_path_length(Floyd-Warshallmethods and a precomputedspare declined)eccentricity,diameter,radius,centerandperipheryraiseOverflowErrorwhere integer lengths could pass 2**63Stacked on #111.