ZTWHHH commited on
Commit
e6375cf
·
verified ·
1 Parent(s): ce3f3b5

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. parrot/lib/libgomp.so +3 -0
  3. parrot/lib/python3.10/site-packages/idna/__pycache__/idnadata.cpython-310.pyc +3 -0
  4. parrot/lib/python3.10/site-packages/networkx/algorithms/approximation/__init__.py +24 -0
  5. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/__init__.cpython-310.pyc +0 -0
  6. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/betweenness.cpython-310.pyc +0 -0
  7. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/betweenness_subset.cpython-310.pyc +0 -0
  8. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/closeness.cpython-310.pyc +0 -0
  9. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/current_flow_betweenness.cpython-310.pyc +0 -0
  10. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/current_flow_closeness.cpython-310.pyc +0 -0
  11. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/degree_alg.cpython-310.pyc +0 -0
  12. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/dispersion.cpython-310.pyc +0 -0
  13. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/eigenvector.cpython-310.pyc +0 -0
  14. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/flow_matrix.cpython-310.pyc +0 -0
  15. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/group.cpython-310.pyc +0 -0
  16. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/harmonic.cpython-310.pyc +0 -0
  17. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/katz.cpython-310.pyc +0 -0
  18. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/laplacian.cpython-310.pyc +0 -0
  19. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/load.cpython-310.pyc +0 -0
  20. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/percolation.cpython-310.pyc +0 -0
  21. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/reaching.cpython-310.pyc +0 -0
  22. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/second_order.cpython-310.pyc +0 -0
  23. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/subgraph_alg.cpython-310.pyc +0 -0
  24. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/trophic.cpython-310.pyc +0 -0
  25. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/voterank_alg.cpython-310.pyc +0 -0
  26. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  27. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_betweenness_centrality.cpython-310.pyc +0 -0
  28. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_betweenness_centrality_subset.cpython-310.pyc +0 -0
  29. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_closeness_centrality.cpython-310.pyc +0 -0
  30. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_current_flow_betweenness_centrality.cpython-310.pyc +0 -0
  31. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_current_flow_betweenness_centrality_subset.cpython-310.pyc +0 -0
  32. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_current_flow_closeness.cpython-310.pyc +0 -0
  33. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_degree_centrality.cpython-310.pyc +0 -0
  34. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_dispersion.cpython-310.pyc +0 -0
  35. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_eigenvector_centrality.cpython-310.pyc +0 -0
  36. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_group.cpython-310.pyc +0 -0
  37. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_harmonic_centrality.cpython-310.pyc +0 -0
  38. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_katz_centrality.cpython-310.pyc +0 -0
  39. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_laplacian_centrality.cpython-310.pyc +0 -0
  40. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_load_centrality.cpython-310.pyc +0 -0
  41. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_reaching.cpython-310.pyc +0 -0
  42. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_second_order_centrality.cpython-310.pyc +0 -0
  43. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_subgraph.cpython-310.pyc +0 -0
  44. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_trophic.cpython-310.pyc +0 -0
  45. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_voterank.cpython-310.pyc +0 -0
  46. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_harmonic_centrality.py +115 -0
  47. parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_second_order_centrality.py +82 -0
  48. parrot/lib/python3.10/site-packages/networkx/algorithms/community/__init__.py +25 -0
  49. parrot/lib/python3.10/site-packages/networkx/algorithms/community/__pycache__/asyn_fluid.cpython-310.pyc +0 -0
  50. parrot/lib/python3.10/site-packages/networkx/algorithms/community/__pycache__/centrality.cpython-310.pyc +0 -0
.gitattributes CHANGED
@@ -164,3 +164,5 @@ parrot/lib/libsqlite3.so.0 filter=lfs diff=lfs merge=lfs -text
164
  parrot/lib/python3.10/site-packages/imageio/plugins/__pycache__/_tifffile.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
165
  parrot/lib/libgomp.so.1.0.0 filter=lfs diff=lfs merge=lfs -text
166
  parrot/lib/python3.10/site-packages/idna/__pycache__/uts46data.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
 
 
 
164
  parrot/lib/python3.10/site-packages/imageio/plugins/__pycache__/_tifffile.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
165
  parrot/lib/libgomp.so.1.0.0 filter=lfs diff=lfs merge=lfs -text
166
  parrot/lib/python3.10/site-packages/idna/__pycache__/uts46data.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
167
+ parrot/lib/python3.10/site-packages/idna/__pycache__/idnadata.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
168
+ parrot/lib/libgomp.so filter=lfs diff=lfs merge=lfs -text
parrot/lib/libgomp.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3b68c5f37afb7b70bd12273b69706ab33a397714e8336910f0e47f8f1cf6854
3
+ size 1265616
parrot/lib/python3.10/site-packages/idna/__pycache__/idnadata.cpython-310.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d99ad9df73938b30b685b9a48835991fee86ea6e7d7705c3ad87d6e7011dfa1f
3
+ size 194416
parrot/lib/python3.10/site-packages/networkx/algorithms/approximation/__init__.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Approximations of graph properties and Heuristic methods for optimization.
2
+
3
+ The functions in this class are not imported into the top-level ``networkx``
4
+ namespace so the easiest way to use them is with::
5
+
6
+ >>> from networkx.algorithms import approximation
7
+
8
+ Another option is to import the specific function with
9
+ ``from networkx.algorithms.approximation import function_name``.
10
+
11
+ """
12
+ from networkx.algorithms.approximation.clustering_coefficient import *
13
+ from networkx.algorithms.approximation.clique import *
14
+ from networkx.algorithms.approximation.connectivity import *
15
+ from networkx.algorithms.approximation.distance_measures import *
16
+ from networkx.algorithms.approximation.dominating_set import *
17
+ from networkx.algorithms.approximation.kcomponents import *
18
+ from networkx.algorithms.approximation.matching import *
19
+ from networkx.algorithms.approximation.ramsey import *
20
+ from networkx.algorithms.approximation.steinertree import *
21
+ from networkx.algorithms.approximation.traveling_salesman import *
22
+ from networkx.algorithms.approximation.treewidth import *
23
+ from networkx.algorithms.approximation.vertex_cover import *
24
+ from networkx.algorithms.approximation.maxcut import *
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (665 Bytes). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/betweenness.cpython-310.pyc ADDED
Binary file (12.3 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/betweenness_subset.cpython-310.pyc ADDED
Binary file (8.21 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/closeness.cpython-310.pyc ADDED
Binary file (9.16 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/current_flow_betweenness.cpython-310.pyc ADDED
Binary file (11.3 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/current_flow_closeness.cpython-310.pyc ADDED
Binary file (3.36 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/degree_alg.cpython-310.pyc ADDED
Binary file (4.55 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/dispersion.cpython-310.pyc ADDED
Binary file (3.29 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/eigenvector.cpython-310.pyc ADDED
Binary file (12.7 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/flow_matrix.cpython-310.pyc ADDED
Binary file (5.08 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/group.cpython-310.pyc ADDED
Binary file (21.5 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/harmonic.cpython-310.pyc ADDED
Binary file (2.83 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/katz.cpython-310.pyc ADDED
Binary file (10.8 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/laplacian.cpython-310.pyc ADDED
Binary file (5.5 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/load.cpython-310.pyc ADDED
Binary file (5.67 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/percolation.cpython-310.pyc ADDED
Binary file (4.15 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/reaching.cpython-310.pyc ADDED
Binary file (6.69 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/second_order.cpython-310.pyc ADDED
Binary file (5.39 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/subgraph_alg.cpython-310.pyc ADDED
Binary file (9.27 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/trophic.cpython-310.pyc ADDED
Binary file (4.28 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/__pycache__/voterank_alg.cpython-310.pyc ADDED
Binary file (2.9 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (188 Bytes). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_betweenness_centrality.cpython-310.pyc ADDED
Binary file (21.1 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_betweenness_centrality_subset.cpython-310.pyc ADDED
Binary file (10.9 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_closeness_centrality.cpython-310.pyc ADDED
Binary file (9.31 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_current_flow_betweenness_centrality.cpython-310.pyc ADDED
Binary file (7.96 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_current_flow_betweenness_centrality_subset.cpython-310.pyc ADDED
Binary file (4.36 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_current_flow_closeness.cpython-310.pyc ADDED
Binary file (2.09 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_degree_centrality.cpython-310.pyc ADDED
Binary file (3.98 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_dispersion.cpython-310.pyc ADDED
Binary file (2.26 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_eigenvector_centrality.cpython-310.pyc ADDED
Binary file (5.79 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_group.cpython-310.pyc ADDED
Binary file (10.1 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_harmonic_centrality.cpython-310.pyc ADDED
Binary file (5.05 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_katz_centrality.cpython-310.pyc ADDED
Binary file (9.5 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_laplacian_centrality.cpython-310.pyc ADDED
Binary file (6.05 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_load_centrality.cpython-310.pyc ADDED
Binary file (9.54 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_reaching.cpython-310.pyc ADDED
Binary file (5.66 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_second_order_centrality.cpython-310.pyc ADDED
Binary file (2.77 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_subgraph.cpython-310.pyc ADDED
Binary file (3.01 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_trophic.cpython-310.pyc ADDED
Binary file (7.14 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_voterank.cpython-310.pyc ADDED
Binary file (2.23 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_harmonic_centrality.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Tests for degree centrality.
3
+ """
4
+ import pytest
5
+
6
+ import networkx as nx
7
+ from networkx.algorithms.centrality import harmonic_centrality
8
+
9
+
10
+ class TestClosenessCentrality:
11
+ @classmethod
12
+ def setup_class(cls):
13
+ cls.P3 = nx.path_graph(3)
14
+ cls.P4 = nx.path_graph(4)
15
+ cls.K5 = nx.complete_graph(5)
16
+
17
+ cls.C4 = nx.cycle_graph(4)
18
+ cls.C4_directed = nx.cycle_graph(4, create_using=nx.DiGraph)
19
+
20
+ cls.C5 = nx.cycle_graph(5)
21
+
22
+ cls.T = nx.balanced_tree(r=2, h=2)
23
+
24
+ cls.Gb = nx.DiGraph()
25
+ cls.Gb.add_edges_from([(0, 1), (0, 2), (0, 4), (2, 1), (2, 3), (4, 3)])
26
+
27
+ def test_p3_harmonic(self):
28
+ c = harmonic_centrality(self.P3)
29
+ d = {0: 1.5, 1: 2, 2: 1.5}
30
+ for n in sorted(self.P3):
31
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
32
+
33
+ def test_p4_harmonic(self):
34
+ c = harmonic_centrality(self.P4)
35
+ d = {0: 1.8333333, 1: 2.5, 2: 2.5, 3: 1.8333333}
36
+ for n in sorted(self.P4):
37
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
38
+
39
+ def test_clique_complete(self):
40
+ c = harmonic_centrality(self.K5)
41
+ d = {0: 4, 1: 4, 2: 4, 3: 4, 4: 4}
42
+ for n in sorted(self.P3):
43
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
44
+
45
+ def test_cycle_C4(self):
46
+ c = harmonic_centrality(self.C4)
47
+ d = {0: 2.5, 1: 2.5, 2: 2.5, 3: 2.5}
48
+ for n in sorted(self.C4):
49
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
50
+
51
+ def test_cycle_C5(self):
52
+ c = harmonic_centrality(self.C5)
53
+ d = {0: 3, 1: 3, 2: 3, 3: 3, 4: 3, 5: 4}
54
+ for n in sorted(self.C5):
55
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
56
+
57
+ def test_bal_tree(self):
58
+ c = harmonic_centrality(self.T)
59
+ d = {0: 4.0, 1: 4.1666, 2: 4.1666, 3: 2.8333, 4: 2.8333, 5: 2.8333, 6: 2.8333}
60
+ for n in sorted(self.T):
61
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
62
+
63
+ def test_exampleGraph(self):
64
+ c = harmonic_centrality(self.Gb)
65
+ d = {0: 0, 1: 2, 2: 1, 3: 2.5, 4: 1}
66
+ for n in sorted(self.Gb):
67
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
68
+
69
+ def test_weighted_harmonic(self):
70
+ XG = nx.DiGraph()
71
+ XG.add_weighted_edges_from(
72
+ [
73
+ ("a", "b", 10),
74
+ ("d", "c", 5),
75
+ ("a", "c", 1),
76
+ ("e", "f", 2),
77
+ ("f", "c", 1),
78
+ ("a", "f", 3),
79
+ ]
80
+ )
81
+ c = harmonic_centrality(XG, distance="weight")
82
+ d = {"a": 0, "b": 0.1, "c": 2.533, "d": 0, "e": 0, "f": 0.83333}
83
+ for n in sorted(XG):
84
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
85
+
86
+ def test_empty(self):
87
+ G = nx.DiGraph()
88
+ c = harmonic_centrality(G, distance="weight")
89
+ d = {}
90
+ assert c == d
91
+
92
+ def test_singleton(self):
93
+ G = nx.DiGraph()
94
+ G.add_node(0)
95
+ c = harmonic_centrality(G, distance="weight")
96
+ d = {0: 0}
97
+ assert c == d
98
+
99
+ def test_cycle_c4_directed(self):
100
+ c = harmonic_centrality(self.C4_directed, nbunch=[0, 1], sources=[1, 2])
101
+ d = {0: 0.833, 1: 0.333}
102
+ for n in [0, 1]:
103
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
104
+
105
+ def test_p3_harmonic_subset(self):
106
+ c = harmonic_centrality(self.P3, sources=[0, 1])
107
+ d = {0: 1, 1: 1, 2: 1.5}
108
+ for n in self.P3:
109
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
110
+
111
+ def test_p4_harmonic_subset(self):
112
+ c = harmonic_centrality(self.P4, nbunch=[2, 3], sources=[0, 1])
113
+ d = {2: 1.5, 3: 0.8333333}
114
+ for n in [2, 3]:
115
+ assert c[n] == pytest.approx(d[n], abs=1e-3)
parrot/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_second_order_centrality.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Tests for second order centrality.
3
+ """
4
+
5
+ import pytest
6
+
7
+ pytest.importorskip("numpy")
8
+ pytest.importorskip("scipy")
9
+
10
+ import networkx as nx
11
+
12
+
13
+ def test_empty():
14
+ with pytest.raises(nx.NetworkXException):
15
+ G = nx.empty_graph()
16
+ nx.second_order_centrality(G)
17
+
18
+
19
+ def test_non_connected():
20
+ with pytest.raises(nx.NetworkXException):
21
+ G = nx.Graph()
22
+ G.add_node(0)
23
+ G.add_node(1)
24
+ nx.second_order_centrality(G)
25
+
26
+
27
+ def test_non_negative_edge_weights():
28
+ with pytest.raises(nx.NetworkXException):
29
+ G = nx.path_graph(2)
30
+ G.add_edge(0, 1, weight=-1)
31
+ nx.second_order_centrality(G)
32
+
33
+
34
+ def test_weight_attribute():
35
+ G = nx.Graph()
36
+ G.add_weighted_edges_from([(0, 1, 1.0), (1, 2, 3.5)], weight="w")
37
+ expected = {0: 3.431, 1: 3.082, 2: 5.612}
38
+ b = nx.second_order_centrality(G, weight="w")
39
+
40
+ for n in sorted(G):
41
+ assert b[n] == pytest.approx(expected[n], abs=1e-2)
42
+
43
+
44
+ def test_one_node_graph():
45
+ """Second order centrality: single node"""
46
+ G = nx.Graph()
47
+ G.add_node(0)
48
+ G.add_edge(0, 0)
49
+ assert nx.second_order_centrality(G)[0] == 0
50
+
51
+
52
+ def test_P3():
53
+ """Second order centrality: line graph, as defined in paper"""
54
+ G = nx.path_graph(3)
55
+ b_answer = {0: 3.741, 1: 1.414, 2: 3.741}
56
+
57
+ b = nx.second_order_centrality(G)
58
+
59
+ for n in sorted(G):
60
+ assert b[n] == pytest.approx(b_answer[n], abs=1e-2)
61
+
62
+
63
+ def test_K3():
64
+ """Second order centrality: complete graph, as defined in paper"""
65
+ G = nx.complete_graph(3)
66
+ b_answer = {0: 1.414, 1: 1.414, 2: 1.414}
67
+
68
+ b = nx.second_order_centrality(G)
69
+
70
+ for n in sorted(G):
71
+ assert b[n] == pytest.approx(b_answer[n], abs=1e-2)
72
+
73
+
74
+ def test_ring_graph():
75
+ """Second order centrality: ring graph, as defined in paper"""
76
+ G = nx.cycle_graph(5)
77
+ b_answer = {0: 4.472, 1: 4.472, 2: 4.472, 3: 4.472, 4: 4.472}
78
+
79
+ b = nx.second_order_centrality(G)
80
+
81
+ for n in sorted(G):
82
+ assert b[n] == pytest.approx(b_answer[n], abs=1e-2)
parrot/lib/python3.10/site-packages/networkx/algorithms/community/__init__.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Functions for computing and measuring community structure.
2
+
3
+ The ``community`` subpackage can be accessed by using :mod:`networkx.community`, then accessing the
4
+ functions as attributes of ``community``. For example::
5
+
6
+ >>> import networkx as nx
7
+ >>> G = nx.barbell_graph(5, 1)
8
+ >>> communities_generator = nx.community.girvan_newman(G)
9
+ >>> top_level_communities = next(communities_generator)
10
+ >>> next_level_communities = next(communities_generator)
11
+ >>> sorted(map(sorted, next_level_communities))
12
+ [[0, 1, 2, 3, 4], [5], [6, 7, 8, 9, 10]]
13
+
14
+ """
15
+ from networkx.algorithms.community.asyn_fluid import *
16
+ from networkx.algorithms.community.centrality import *
17
+ from networkx.algorithms.community.divisive import *
18
+ from networkx.algorithms.community.kclique import *
19
+ from networkx.algorithms.community.kernighan_lin import *
20
+ from networkx.algorithms.community.label_propagation import *
21
+ from networkx.algorithms.community.lukes import *
22
+ from networkx.algorithms.community.modularity_max import *
23
+ from networkx.algorithms.community.quality import *
24
+ from networkx.algorithms.community.community_utils import *
25
+ from networkx.algorithms.community.louvain import *
parrot/lib/python3.10/site-packages/networkx/algorithms/community/__pycache__/asyn_fluid.cpython-310.pyc ADDED
Binary file (4.34 kB). View file
 
parrot/lib/python3.10/site-packages/networkx/algorithms/community/__pycache__/centrality.cpython-310.pyc ADDED
Binary file (6.29 kB). View file