### diff 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
line wrap: on
line diff
```--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/env/lib/python3.9/site-packages/networkx/algorithms/approximation/tests/test_approx_clust_coeff.py	Mon Mar 22 18:12:50 2021 +0000
@@ -0,0 +1,43 @@
+import networkx as nx
+from networkx.algorithms.approximation import average_clustering
+
+# This approximation has to be be exact in regular graphs
+# with no triangles or with all possible triangles.
+
+
+def test_petersen():
+    # Actual coefficient is 0
+    G = nx.petersen_graph()
+    assert average_clustering(G, trials=int(len(G) / 2)) == nx.average_clustering(G)
+
+
+def test_petersen_seed():
+    # Actual coefficient is 0
+    G = nx.petersen_graph()
+    assert average_clustering(
+        G, trials=int(len(G) / 2), seed=1
+    ) == nx.average_clustering(G)
+
+
+def test_tetrahedral():
+    # Actual coefficient is 1
+    G = nx.tetrahedral_graph()
+    assert average_clustering(G, trials=int(len(G) / 2)) == nx.average_clustering(G)
+
+
+def test_dodecahedral():
+    # Actual coefficient is 0
+    G = nx.dodecahedral_graph()
+    assert average_clustering(G, trials=int(len(G) / 2)) == nx.average_clustering(G)
+
+
+def test_empty():
+    G = nx.empty_graph(5)
+    assert average_clustering(G, trials=int(len(G) / 2)) == 0
+
+
+def test_complete():
+    G = nx.complete_graph(5)
+    assert average_clustering(G, trials=int(len(G) / 2)) == 1
+    G = nx.complete_graph(7)
+    assert average_clustering(G, trials=int(len(G) / 2)) == 1```