### comparison env/lib/python3.9/site-packages/networkx/algorithms/centrality/tests/test_voterank.py @ 0:4f3585e2f14bdraftdefaulttip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac Mon, 22 Mar 2021 18:12:50 +0000
comparison
equal inserted replaced
-1:000000000000 0:4f3585e2f14b
1 """
2 Unit tests for VoteRank.
3 """
4
5
6 import networkx as nx
7
8
9 class TestVoteRankCentrality:
10 # Example Graph present in reference paper
11 def test_voterank_centrality_1(self):
12 G = nx.Graph()
13 G.add_edges_from(
14 [
15 (7, 8),
16 (7, 5),
17 (7, 9),
18 (5, 0),
19 (0, 1),
20 (0, 2),
21 (0, 3),
22 (0, 4),
23 (1, 6),
24 (2, 6),
25 (3, 6),
26 (4, 6),
27 ]
28 )
29 assert [0, 7, 6] == nx.voterank(G)
30
31 # Graph unit test
32 def test_voterank_centrality_2(self):
33 G = nx.florentine_families_graph()
34 d = nx.voterank(G, 4)
35 exact = ["Medici", "Strozzi", "Guadagni", "Castellani"]
36 assert exact == d
37
38 # DiGraph unit test
39 def test_voterank_centrality_3(self):
40 G = nx.gnc_graph(10, seed=7)
41 d = nx.voterank(G, 4)
42 exact = [3, 6, 8]
43 assert exact == d
44
45 # MultiGraph unit test
46 def test_voterank_centrality_4(self):
47 G = nx.MultiGraph()
48 G.add_edges_from(
49 [(0, 1), (0, 1), (1, 2), (2, 5), (2, 5), (5, 6), (5, 6), (2, 4), (4, 3)]
50 )
51 exact = [2, 1, 5, 4]
52 assert exact == nx.voterank(G)
53
54 # MultiDiGraph unit test
55 def test_voterank_centrality_5(self):
56 G = nx.MultiDiGraph()
57 G.add_edges_from(
58 [(0, 1), (0, 1), (1, 2), (2, 5), (2, 5), (5, 6), (5, 6), (2, 4), (4, 3)]
59 )
60 exact = [2, 0, 5, 4]
61 assert exact == nx.voterank(G)