rm CondaPkg environment

This commit is contained in:
ton
2023-04-06 13:53:47 +07:00
parent 0a57ed7884
commit c43d949309
3329 changed files with 5725 additions and 447022 deletions

View File

@@ -115,6 +115,7 @@ def hopcroft_karp_matching(G, top_nodes=None):
2.4 (1973), pp. 225--231. <https://doi.org/10.1137/0202019>.
"""
# First we define some auxiliary search functions.
#
# If you are a human reading these auxiliary search functions, the "global"
@@ -269,12 +270,17 @@ def eppstein_matching(G, top_nodes=None):
# did we finish layering without finding any alternating paths?
if not unmatched:
unlayered = {}
for u in G:
# TODO Why is extra inner loop necessary?
for v in G[u]:
if v not in preds:
unlayered[v] = None
# TODO - The lines between --- were unused and were thus commented
# out. This whole commented chunk should be reviewed to determine
# whether it should be built upon or completely removed.
# ---
# unlayered = {}
# for u in G:
# # TODO Why is extra inner loop necessary?
# for v in G[u]:
# if v not in preds:
# unlayered[v] = None
# ---
# TODO Originally, this function returned a three-tuple:
#
# return (matching, list(pred), list(unlayered))

View File

@@ -1,7 +1,7 @@
import pytest
import networkx as nx
import networkx.algorithms.bipartite as bipartite
from networkx.algorithms import bipartite
from networkx.algorithms.bipartite.cluster import cc_dot, cc_max, cc_min

View File

@@ -1,5 +1,5 @@
import networkx as nx
import networkx.algorithms.bipartite as bipartite
from networkx.algorithms import bipartite
class TestMinEdgeCover:

View File

@@ -190,3 +190,40 @@ class TestEdgelist:
G = nx.path_graph(4)
bytesIO = io.BytesIO()
bipartite.write_edgelist(G, bytesIO)
def test_parse_edgelist(self):
"""Tests for conditions specific to
parse_edge_list method"""
# ignore strings of length less than 2
lines = ["1 2", "2 3", "3 1", "4", " "]
G = bipartite.parse_edgelist(lines, nodetype=int)
assert list(G.nodes) == [1, 2, 3]
# Exception raised when node is not convertible
# to specified data type
with pytest.raises(TypeError, match=".*Failed to convert nodes"):
lines = ["a b", "b c", "c a"]
G = bipartite.parse_edgelist(lines, nodetype=int)
# Exception raised when format of data is not
# convertible to dictionary object
with pytest.raises(TypeError, match=".*Failed to convert edge data"):
lines = ["1 2 3", "2 3 4", "3 1 2"]
G = bipartite.parse_edgelist(lines, nodetype=int)
# Exception raised when edge data and data
# keys are not of same length
with pytest.raises(IndexError):
lines = ["1 2 3 4", "2 3 4"]
G = bipartite.parse_edgelist(
lines, nodetype=int, data=[("weight", int), ("key", int)]
)
# Exception raised when edge data is not
# convertible to specified data type
with pytest.raises(TypeError, match=".*Failed to convert key data"):
lines = ["1 2 3 a", "2 3 4 b"]
G = bipartite.parse_edgelist(
lines, nodetype=int, data=[("weight", int), ("key", int)]
)

View File

@@ -104,7 +104,7 @@ class TestMatching:
# the number of vertices in a minimum vertex cover.
assert len(vertices) == 5
# Assert that the set is truly a vertex cover.
for (u, v) in self.graph.edges():
for u, v in self.graph.edges():
assert u in vertices or v in vertices
# TODO Assert that the vertices are the correct ones.

View File

@@ -14,6 +14,9 @@ class TestBipartiteProject:
P = bipartite.projected_graph(G, [0, 2])
assert nodes_equal(list(P), [0, 2])
assert edges_equal(list(P.edges()), [(0, 2)])
G = nx.MultiGraph([(0, 1)])
with pytest.raises(nx.NetworkXError, match="not defined for multigraphs"):
bipartite.projected_graph(G, [0])
def test_path_projected_properties_graph(self):
G = nx.path_graph(4)
@@ -66,6 +69,12 @@ class TestBipartiteProject:
assert edges_equal(list(P.edges()), [(0, 2)])
P[0][2]["weight"] = 1
def test_digraph_weighted_projection(self):
G = nx.DiGraph([(0, 1), (1, 2), (2, 3), (3, 4)])
P = bipartite.overlap_weighted_projected_graph(G, [1, 3])
assert nx.get_edge_attributes(P, "weight") == {(1, 3): 1.0}
assert len(P) == 2
def test_path_weighted_projected_directed_graph(self):
G = nx.DiGraph()
nx.add_path(G, range(4))
@@ -353,14 +362,14 @@ class TestBipartiteWeightedProjection:
)
assert nodes_equal(list(G), [0, 2, 4])
assert edges_equal(
list(list(G.edges(data=True))),
list(G.edges(data=True)),
[(0, 2, {"weight": 1}), (2, 4, {"weight": 1})],
)
G = bipartite.generic_weighted_projected_graph(B, [0, 2, 4])
assert nodes_equal(list(G), [0, 2, 4])
assert edges_equal(
list(list(G.edges(data=True))),
list(G.edges(data=True)),
[(0, 2, {"weight": 1}), (2, 4, {"weight": 1})],
)
B = nx.DiGraph()

View File

@@ -10,9 +10,15 @@ from networkx.algorithms.bipartite import complete_bipartite_graph, node_redunda
def test_no_redundant_nodes():
G = complete_bipartite_graph(2, 2)
# when nodes is None
rc = node_redundancy(G)
assert all(redundancy == 1 for redundancy in rc.values())
# when set of nodes is specified
rc = node_redundancy(G, (2, 3))
assert rc == {2: 1.0, 3: 1.0}
def test_redundant_nodes():
G = cycle_graph(6)

View File

@@ -66,7 +66,6 @@ class TestSpectralBipartivity:
assert sb(G) == pytest.approx(0.597, abs=1e-3)
def test_single_nodes(self):
# single nodes
G = nx.complete_bipartite_graph(2, 3)
G.add_edge(2, 4)