Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/networkx/algorithms/bipartite/tests/test_redundancy.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 """Unit tests for the :mod:`networkx.algorithms.bipartite.redundancy` module. | |
2 | |
3 """ | |
4 | |
5 import pytest | |
6 | |
7 from networkx import cycle_graph | |
8 from networkx import NetworkXError | |
9 from networkx.algorithms.bipartite import complete_bipartite_graph | |
10 from networkx.algorithms.bipartite import node_redundancy | |
11 | |
12 | |
13 def test_no_redundant_nodes(): | |
14 G = complete_bipartite_graph(2, 2) | |
15 rc = node_redundancy(G) | |
16 assert all(redundancy == 1 for redundancy in rc.values()) | |
17 | |
18 | |
19 def test_redundant_nodes(): | |
20 G = cycle_graph(6) | |
21 edge = {0, 3} | |
22 G.add_edge(*edge) | |
23 redundancy = node_redundancy(G) | |
24 for v in edge: | |
25 assert redundancy[v] == 2 / 3 | |
26 for v in set(G) - edge: | |
27 assert redundancy[v] == 1 | |
28 | |
29 | |
30 def test_not_enough_neighbors(): | |
31 with pytest.raises(NetworkXError): | |
32 G = complete_bipartite_graph(1, 2) | |
33 node_redundancy(G) |