## iof-tools / networkxMiCe / networkx-master / networkx / algorithms / tests / test_distance_regular.py @ 5cef0f13

History | View | Annotate | Download (2.49 KB)

1 | 5cef0f13 | tiamilani | from nose.tools import assert_equal |
---|---|---|---|

2 | from nose.tools import assert_false |
||

3 | from nose.tools import assert_true |
||

4 | |||

5 | import networkx as nx |
||

6 | from networkx import is_strongly_regular |
||

7 | |||

8 | |||

9 | class TestDistanceRegular(object): |
||

10 | |||

11 | def test_is_distance_regular(self): |
||

12 | assert_true(nx.is_distance_regular(nx.icosahedral_graph())) |
||

13 | assert_true(nx.is_distance_regular(nx.petersen_graph())) |
||

14 | assert_true(nx.is_distance_regular(nx.cubical_graph())) |
||

15 | assert_true(nx.is_distance_regular(nx.complete_bipartite_graph(3, 3))) |
||

16 | assert_true(nx.is_distance_regular(nx.tetrahedral_graph())) |
||

17 | assert_true(nx.is_distance_regular(nx.dodecahedral_graph())) |
||

18 | assert_true(nx.is_distance_regular(nx.pappus_graph())) |
||

19 | assert_true(nx.is_distance_regular(nx.heawood_graph())) |
||

20 | ```
assert_true(nx.is_distance_regular(nx.cycle_graph(3)))
``` |
||

21 | ```
# no distance regular
``` |
||

22 | ```
assert_false(nx.is_distance_regular(nx.path_graph(4)))
``` |
||

23 | |||

24 | def test_not_connected(self): |
||

25 | ```
G = nx.cycle_graph(4)
``` |
||

26 | nx.add_cycle(G, [5, 6, 7]) |
||

27 | assert_false(nx.is_distance_regular(G)) |
||

28 | |||

29 | def test_global_parameters(self): |
||

30 | ```
b, c = nx.intersection_array(nx.cycle_graph(5))
``` |
||

31 | g = nx.global_parameters(b, c) |
||

32 | assert_equal(list(g), [(0, 0, 2), (1, 0, 1), (1, 1, 0)]) |
||

33 | ```
b, c = nx.intersection_array(nx.cycle_graph(3))
``` |
||

34 | g = nx.global_parameters(b, c) |
||

35 | assert_equal(list(g), [(0, 0, 2), (1, 1, 0)]) |
||

36 | |||

37 | def test_intersection_array(self): |
||

38 | ```
b, c = nx.intersection_array(nx.cycle_graph(5))
``` |
||

39 | assert_equal(b, [2, 1]) |
||

40 | assert_equal(c, [1, 1]) |
||

41 | b, c = nx.intersection_array(nx.dodecahedral_graph()) |
||

42 | assert_equal(b, [3, 2, 1, 1, 1]) |
||

43 | assert_equal(c, [1, 1, 1, 2, 3]) |
||

44 | b, c = nx.intersection_array(nx.icosahedral_graph()) |
||

45 | assert_equal(b, [5, 2, 1]) |
||

46 | assert_equal(c, [1, 2, 5]) |
||

47 | |||

48 | |||

49 | class TestStronglyRegular(object): |
||

50 | ```
"""Unit tests for the :func:`~networkx.is_strongly_regular`
``` |
||

51 | ```
function.
``` |
||

52 | ```
``` |
||

53 | ```
"""
``` |
||

54 | |||

55 | def test_cycle_graph(self): |
||

56 | ```
"""Tests that the cycle graph on five vertices is strongly
``` |
||

57 | ```
regular.
``` |
||

58 | ```
``` |
||

59 | ```
"""
``` |
||

60 | ```
G = nx.cycle_graph(5)
``` |
||

61 | assert_true(is_strongly_regular(G)) |
||

62 | |||

63 | def test_petersen_graph(self): |
||

64 | ```
"""Tests that the Petersen graph is strongly regular."""
``` |
||

65 | G = nx.petersen_graph() |
||

66 | assert_true(is_strongly_regular(G)) |
||

67 | |||

68 | def test_path_graph(self): |
||

69 | ```
"""Tests that the path graph is not strongly regular."""
``` |
||

70 | ```
G = nx.path_graph(4)
``` |
||

71 | assert_false(is_strongly_regular(G)) |