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

author shellac Mon, 22 Mar 2021 18:12:50 +0000
comparison
equal inserted replaced
-1:000000000000 0:4f3585e2f14b
1 import networkx as nx
2 from networkx.algorithms.approximation import average_clustering
3
4 # This approximation has to be be exact in regular graphs
5 # with no triangles or with all possible triangles.
6
7
8 def test_petersen():
9 # Actual coefficient is 0
10 G = nx.petersen_graph()
11 assert average_clustering(G, trials=int(len(G) / 2)) == nx.average_clustering(G)
12
13
14 def test_petersen_seed():
15 # Actual coefficient is 0
16 G = nx.petersen_graph()
17 assert average_clustering(
18 G, trials=int(len(G) / 2), seed=1
19 ) == nx.average_clustering(G)
20
21
22 def test_tetrahedral():
23 # Actual coefficient is 1
24 G = nx.tetrahedral_graph()
25 assert average_clustering(G, trials=int(len(G) / 2)) == nx.average_clustering(G)
26
27
28 def test_dodecahedral():
29 # Actual coefficient is 0
30 G = nx.dodecahedral_graph()
31 assert average_clustering(G, trials=int(len(G) / 2)) == nx.average_clustering(G)
32
33
34 def test_empty():
35 G = nx.empty_graph(5)
36 assert average_clustering(G, trials=int(len(G) / 2)) == 0
37
38
39 def test_complete():
40 G = nx.complete_graph(5)
41 assert average_clustering(G, trials=int(len(G) / 2)) == 1
42 G = nx.complete_graph(7)
43 assert average_clustering(G, trials=int(len(G) / 2)) == 1