Repository navigation
31 node attrs - #130
Open
eriknw wants to merge 1 commit into
Open
31 node attrs#130eriknw wants to merge 1 commit into
eriknw wants to merge 1 commit into
Conversation
NetworkX asks the conversion for the node attribute that attribute_assortativity_coefficient, numeric_assortativity_coefficient, attribute_mixing_matrix, attribute_mixing_dict and node_attribute_xy read, and the conversion refused every request for node attributes, so they always fell back. It now carries the named attribute for the names that read one: each value numbered as a dict keys it, and a node without it read as None, as NetworkX's mixing reads it. Other names still have node attributes refused. The value pairs along the edges are counted with GraphBLAS. The coefficients come from the counts in float64, within rounding of NetworkX's, for any number of values; where NetworkX squares ints past about 3e9 in int64, which wraps, the numeric coefficient is the true one. NetworkX meets the values along each node's neighbors, in the order the edges were added, which a matrix does not keep. Without a mapping the mixing matrix numbers them in the order nodes first hold them, where NetworkX's numbering is a set's arbitrary order, and the mixing dict's keys and node_attribute_xy's pairs come in the matrix's order. A graph class with its own adjacency or nodes, an attribute that is None, callable or unhashable, and values no dict can key are left to NetworkX.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 26-overflow-fallback #130 +/- ##
========================================================
+ Coverage 93.47% 93.73% +0.25%
========================================================
Files 194 196 +2
Lines 12466 13062 +596
Branches 1444 1522 +78
========================================================
+ Hits 11653 12244 +591
- Misses 555 560 +5
Partials 258 258 🚀 New features to boost your workflow:
|
eriknw
force-pushed
the
26-overflow-fallback
branch
from
December 3, 2026 00:04
9e518bb to
4dca4dc
Compare
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.
Serve
attribute_assortativity_coefficient,numeric_assortativity_coefficient,attribute_mixing_matrix,attribute_mixing_dictandnode_attribute_xy. NetworkX asks the conversion for the node attribute these names read (node_attrs="attribute"), and the conversion refused every request for node attributes, so they always fell back. It now carries the named attribute for these names only: each node's value, numbered as a dict keys it (1, 1.0 and True are one value, as in NetworkX's counts). The value pairs along the edges are counted in two sparse products, and the answers come from those counts.attribute_assortativity_coefficientis (trace - a . b) / (1 - a . b) of the pairs' joint distribution, as NetworkX'sattribute_accomputes it from a dense matrix; over the tests' graphs and values it was within 9.7e-16 of NetworkX's.numeric_assortativity_coefficientis the Pearson correlation of the pairs whose two values are held by nodes innodes, with the moments taken about the means; it was within 2.2e-16 of the correlation computed exactly from NetworkX's pairs. Neither has a limit on the number of distinct values now.nodesholds, where NetworkX's changes.mapping, NetworkX numbers the values ofattribute_mixing_matrixas a set of them iterates; here they are numbered in the order nodes first hold them, with None for a missing value last unless a node holds None.attribute_mixing_dicthas NetworkX's keys and counts, its keys in another order, andnode_attribute_xyyields NetworkX's pairs edge by edge as the matrix stores them, not along each node's adjacency. With amapping, the matrix is NetworkX's.None, as in NetworkX's mixing;numeric_assortativity_coefficientraisesKeyErrorfor it, as NetworkX doesadjacencyornodes, as the conversion reads the graph's own adjacency and node data; anattributethat is None, callable or unhashable; values no dict can key (lists); fornumeric_assortativity_coefficient, values that are not real numbers, where NetworkX raises, and an iteratornodes, which NetworkX reads twiceG.nodes[n]["a"] = x) is not seen, since it empties no NetworkX cache, as for edge data;nx.set_node_attributes,add_node,add_edgeandremove_nodeare seenattribute_assortativity_coefficient5.3 ms where it took 13.4,attribute_mixing_matrix4.9 where 13.2,numeric_assortativity_coefficient5.1 as before, and, newly served,attribute_mixing_dict5.0 ms where NetworkX took 820 andlist(node_attribute_xy(...))144 where NetworkX took 743. Medians of five calls in each of three interleaved rounds. Indicative, load 8 to 11. Peak memory stayed under 0.8 GBStacked on #126.