Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/networkx/algorithms/bipartite/tests/test_covering.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 import networkx as nx | |
2 import networkx.algorithms.bipartite as bipartite | |
3 | |
4 | |
5 class TestMinEdgeCover: | |
6 """Tests for :func:`networkx.algorithms.bipartite.min_edge_cover`""" | |
7 | |
8 def test_empty_graph(self): | |
9 G = nx.Graph() | |
10 assert bipartite.min_edge_cover(G) == set() | |
11 | |
12 def test_graph_single_edge(self): | |
13 G = nx.Graph() | |
14 G.add_edge(0, 1) | |
15 assert bipartite.min_edge_cover(G) == {(0, 1), (1, 0)} | |
16 | |
17 def test_bipartite_default(self): | |
18 G = nx.Graph() | |
19 G.add_nodes_from([1, 2, 3, 4], bipartite=0) | |
20 G.add_nodes_from(["a", "b", "c"], bipartite=1) | |
21 G.add_edges_from([(1, "a"), (1, "b"), (2, "b"), (2, "c"), (3, "c"), (4, "a")]) | |
22 min_cover = bipartite.min_edge_cover(G) | |
23 assert nx.is_edge_cover(G, min_cover) | |
24 assert len(min_cover) == 8 | |
25 | |
26 def test_bipartite_explicit(self): | |
27 G = nx.Graph() | |
28 G.add_nodes_from([1, 2, 3, 4], bipartite=0) | |
29 G.add_nodes_from(["a", "b", "c"], bipartite=1) | |
30 G.add_edges_from([(1, "a"), (1, "b"), (2, "b"), (2, "c"), (3, "c"), (4, "a")]) | |
31 min_cover = bipartite.min_edge_cover(G, bipartite.eppstein_matching) | |
32 assert nx.is_edge_cover(G, min_cover) | |
33 assert len(min_cover) == 8 |