Repository navigation
Conversation
A directed graph's closure is a breadth-first search from every node with an out-edge at once, in blocks of sources whose bitmap stays under 64 MB. Its diagonal holds the nodes on a cycle, the self-loops reflexive=False adds; reflexive=True adds one at every node and None adds none but the graph's own. An undirected graph's closure joins each node to the rest of its component, read off the component labels, and as in NetworkX it gains no self-loop there unless reflexive is True. The reduction keeps each edge whose head no walk of two or more edges from its tail reaches, walking only from nodes with two out-edges or more. The results are NetworkX graphs written a row at a time rather than through add_edges_from. As NetworkX's copy does, a closure keeps the graph attributes and each edge's weight, its new edges carry no data, and an edge's data dict is the one both its adjacencies hold; the reduction keeps the nodes and nothing else. A reflexive that only equals a bool, such as 1, adds no edge, as in NetworkX. A cycle raises NetworkXUnfeasible in transitive_closure_dag and NetworkXError in transitive_reduction, as NetworkX's do. A closure of more than 2**24 edges is left to NetworkX, to bound the memory of the graph built. So is a topo_order that is not a list or tuple of every node once in a topological order, since NetworkX does not check it and its answer follows the order given.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 20-wiener-efficiency #150 +/- ##
========================================================
+ Coverage 92.88% 93.15% +0.27%
========================================================
Files 182 183 +1
Lines 11227 11701 +474
Branches 1274 1333 +59
========================================================
+ Hits 10428 10900 +472
- Misses 546 548 +2
Partials 253 253 🚀 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 transitive_closure, transitive_closure_dag and transitive_reduction. Their edges, the data
on them and the nodes are NetworkX's; each node's neighbors come in node order, which may
differ from NetworkX's.
once, in blocks of sources whose bitmap stays under 64 MB (one block up to 8192 nodes). The
diagonal it reaches is the nodes on a cycle, the self-loops
reflexive=Falseadds;Trueadds one at every node, and
Nonenone but the graph's own.component labels. As in NetworkX, whose edge_bfs never walks back along an edge, it gains no
self-loop unless
reflexive=True.each edge whose head no walk of two or more edges from its tail reaches. Only nodes with two
out-edges or more are walked from: a lone out-edge is the only way to its head.
add_edges_from. As NetworkX's
G.copy()does, a closure keeps the graph attributes andeach edge's weight, its new edges carry no data, and an edge's data dict is the one both
its adjacencies hold. The reduction is a plain DiGraph with the nodes and nothing else.
Data a matrix cannot hold (node attributes, two edge attributes, weighted edges beside bare
ones) and a subclass are left to NetworkX by the existing rule for names that rebuild their
input. A weight comes back in the matrix's type, as in those names: where ints and floats
are mixed, 1 comes back as 1.0, and a numpy scalar comes back as a Python number.
reflexivethat only equals a bool, such as 1, 0.0 or numpy's True, adds no edge, as inNetworkX; any other value raises NetworkX's NetworkXError, or TypeError if unhashable. A
cycle raises NetworkXUnfeasible in transitive_closure_dag and NetworkXError in
transitive_reduction, as NetworkX's do.
ways), found while walking and before the NetworkX graph is built. The call peaks at about
215 bytes an edge (NetworkX's own loop at 180 to 205), so about 3.6 GB at the bound; and a
topo_orderthat is not a list or tuple of every node once in a topological order, sinceNetworkX does not check it and its answer follows the order given.
Speed, Indicative (one shared machine at load 3.5 to 4.3; each call in a fresh process from a
NetworkX graph, conversion and building the result included; best of two interleaved rounds):
faster than NetworkX in every case measured, with conversion.
Stacked on #121.