Repository navigation
08 operators - #107
Open
eriknw wants to merge 5 commits into
Open
08 operators#107eriknw wants to merge 5 commits into
eriknw wants to merge 5 commits into
Conversation
When the two graphs had different node sets, compose wrote its result in three blocks, each wrong in its own way: the shared block was assigned rather than accumulated, dropping edges only G had there; the blocks between a shared node and a node only H has were never written; and H's new nodes were numbered by H's own ids plus G's row count, which can address past the end of the matrix. compose([(0, 1), (1, 2)], [(0, 1), (2, 3)]) returned only (0, 1), and compose([(0, 1), (1, 2)], [(2, 3), (3, 4)]) raised KeyError: 3. G's nodes now keep their ids, H's other nodes follow in H's order, and all of H's edges go in with one assignment accumulated by binary.second, so an edge in both graphs takes H's value, as in NetworkX. A graph with no edges no longer disagrees about the edge weight with a weighted operand: compose, union and disjoint_union of an edgeless graph and a weighted one refused, where NetworkX answers with the weighted one's edges.
NetworkX gives the edges a join adds no data, so a full_join where either graph has edge data is a graph of two kinds of edge, bare and weighted, which one matrix cannot hold. The kernel refused it, but only after both graphs were converted. full_join now declines it in can_run, before any conversion, reading NetworkX edge data or a backend graph's weight, and NetworkX builds the result. On backend graphs there is no NetworkX graph to fall back on, so the call raises NotImplementedError; convert with to_networkx() first. full_join's rename defaults to (None, None), as NetworkX's does.
union and full_join rebuild an operand they rename, with prefixed node
keys, and the rebuild started with no graph attributes, so the result
had none: union(G, H, rename=("a", "b")) returned {} where NetworkX
merges the two graphs' attributes. The rebuild now keeps them.
When the node sets overlap, both raise NetworkXError, and NetworkX's
message goes on to name rename and disjoint_union, the part that tells
a caller what to do instead. The message is now NetworkX's in full.
compose, union, disjoint_union, intersection and full_join of a Graph and a DiGraph returned a graph of the first one's type, built from both matrices as they were. With the Graph first, that was an undirected graph whose matrix held some edges in one direction only. NetworkX raises NetworkXError, "All graphs must be directed or undirected.", and now so does this backend. One check serves every operator and takes over their multigraph checks; it runs first, as in NetworkX, so a pair whose edge data would also be refused gets the same error. NetworkX's difference and symmetric_difference accept the pair, and their answer depends on the order in which the Graph reports its edges: Graph([(0, 1)]) built with node 1 first, minus DiGraph([(0, 1)]), keeps the edge, and built with node 0 first it does not. This backend did not follow that order, and its undirected results could be malformed in the same way, so it now declines the pair for those two and NetworkX serves it.
compose, disjoint_union, ego_graph, k_truss, reverse and union return a graph rebuilt from one matrix, so its edge weights come back in the matrix's one type: weights that mix 1 and 2.5 come back as 1.0 and 2.5, an int past 2**53 mixed with floats comes back rounded, and NumPy scalars come back as Python numbers, where NetworkX hands back the objects it was given. Each of these names now says so in the additional_docs NetworkX shows with its documentation. full_join also rebuilds its inputs, but leaves a weighted graph to NetworkX.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 07-counts-cuts #107 +/- ##
==================================================
+ Coverage 85.87% 86.63% +0.76%
==================================================
Files 138 139 +1
Lines 6405 6562 +157
Branches 898 903 +5
==================================================
+ Hits 5500 5685 +185
+ Misses 654 635 -19
+ Partials 251 242 -9 🚀 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.
Fix the graph operators when the two graphs have different node sets or kinds, and decline what one matrix cannot hold so NetworkX builds it.
composeno longer drops edges when the node sets differfull_joinwith edge data is declinedunionandfull_joinwithrenamekeep graph attributes and raise NetworkX's full overlap messageGraphand aDiGraphraisesNetworkXErrorincompose,union,disjoint_union,intersectionandfull_join;differenceandsymmetric_differencedecline the pairStacked on #106.