comparison env/lib/python3.9/site-packages/networkx/generators/tests/test_duplication.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.generators.duplication` module.
2
3 """
4 import pytest
5
6 from networkx.exception import NetworkXError
7 from networkx.generators.duplication import duplication_divergence_graph
8 from networkx.generators.duplication import partial_duplication_graph
9
10
11 class TestDuplicationDivergenceGraph:
12 """Unit tests for the
13 :func:`networkx.generators.duplication.duplication_divergence_graph`
14 function.
15
16 """
17
18 def test_final_size(self):
19 G = duplication_divergence_graph(3, 1)
20 assert len(G) == 3
21 G = duplication_divergence_graph(3, 1, seed=42)
22 assert len(G) == 3
23
24 def test_probability_too_large(self):
25 with pytest.raises(NetworkXError):
26 duplication_divergence_graph(3, 2)
27
28 def test_probability_too_small(self):
29 with pytest.raises(NetworkXError):
30 duplication_divergence_graph(3, -1)
31
32
33 class TestPartialDuplicationGraph:
34 """Unit tests for the
35 :func:`networkx.generators.duplication.partial_duplication_graph`
36 function.
37
38 """
39
40 def test_final_size(self):
41 N = 10
42 n = 5
43 p = 0.5
44 q = 0.5
45 G = partial_duplication_graph(N, n, p, q)
46 assert len(G) == N
47 G = partial_duplication_graph(N, n, p, q, seed=42)
48 assert len(G) == N
49
50 def test_initial_clique_size(self):
51 N = 10
52 n = 10
53 p = 0.5
54 q = 0.5
55 G = partial_duplication_graph(N, n, p, q)
56 assert len(G) == n
57
58 def test_invalid_initial_size(self):
59 with pytest.raises(NetworkXError):
60 N = 5
61 n = 10
62 p = 0.5
63 q = 0.5
64 G = partial_duplication_graph(N, n, p, q)
65
66 def test_invalid_probabilities(self):
67 N = 1
68 n = 1
69 for p, q in [(0.5, 2), (0.5, -1), (2, 0.5), (-1, 0.5)]:
70 args = (N, n, p, q)
71 pytest.raises(NetworkXError, partial_duplication_graph, *args)