comparison env/lib/python3.9/site-packages/networkx/algorithms/tests/test_distance_regular.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 from networkx import is_strongly_regular
3
4
5 class TestDistanceRegular:
6 def test_is_distance_regular(self):
7 assert nx.is_distance_regular(nx.icosahedral_graph())
8 assert nx.is_distance_regular(nx.petersen_graph())
9 assert nx.is_distance_regular(nx.cubical_graph())
10 assert nx.is_distance_regular(nx.complete_bipartite_graph(3, 3))
11 assert nx.is_distance_regular(nx.tetrahedral_graph())
12 assert nx.is_distance_regular(nx.dodecahedral_graph())
13 assert nx.is_distance_regular(nx.pappus_graph())
14 assert nx.is_distance_regular(nx.heawood_graph())
15 assert nx.is_distance_regular(nx.cycle_graph(3))
16 # no distance regular
17 assert not nx.is_distance_regular(nx.path_graph(4))
18
19 def test_not_connected(self):
20 G = nx.cycle_graph(4)
21 nx.add_cycle(G, [5, 6, 7])
22 assert not nx.is_distance_regular(G)
23
24 def test_global_parameters(self):
25 b, c = nx.intersection_array(nx.cycle_graph(5))
26 g = nx.global_parameters(b, c)
27 assert list(g) == [(0, 0, 2), (1, 0, 1), (1, 1, 0)]
28 b, c = nx.intersection_array(nx.cycle_graph(3))
29 g = nx.global_parameters(b, c)
30 assert list(g) == [(0, 0, 2), (1, 1, 0)]
31
32 def test_intersection_array(self):
33 b, c = nx.intersection_array(nx.cycle_graph(5))
34 assert b == [2, 1]
35 assert c == [1, 1]
36 b, c = nx.intersection_array(nx.dodecahedral_graph())
37 assert b == [3, 2, 1, 1, 1]
38 assert c == [1, 1, 1, 2, 3]
39 b, c = nx.intersection_array(nx.icosahedral_graph())
40 assert b == [5, 2, 1]
41 assert c == [1, 2, 5]
42
43
44 class TestStronglyRegular:
45 """Unit tests for the :func:`~networkx.is_strongly_regular`
46 function.
47
48 """
49
50 def test_cycle_graph(self):
51 """Tests that the cycle graph on five vertices is strongly
52 regular.
53
54 """
55 G = nx.cycle_graph(5)
56 assert is_strongly_regular(G)
57
58 def test_petersen_graph(self):
59 """Tests that the Petersen graph is strongly regular."""
60 G = nx.petersen_graph()
61 assert is_strongly_regular(G)
62
63 def test_path_graph(self):
64 """Tests that the path graph is not strongly regular."""
65 G = nx.path_graph(4)
66 assert not is_strongly_regular(G)