Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- ckpts/universal/global_step80/zero/10.mlp.dense_h_to_4h.weight/exp_avg_sq.pt +3 -0
- ckpts/universal/global_step80/zero/17.attention.dense.weight/exp_avg.pt +3 -0
- ckpts/universal/global_step80/zero/17.attention.dense.weight/exp_avg_sq.pt +3 -0
- ckpts/universal/global_step80/zero/25.input_layernorm.weight/exp_avg.pt +3 -0
- ckpts/universal/global_step80/zero/25.input_layernorm.weight/exp_avg_sq.pt +3 -0
- ckpts/universal/global_step80/zero/26.input_layernorm.weight/exp_avg.pt +3 -0
- venv/lib/python3.10/site-packages/networkx/classes/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/__pycache__/coreviews.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/__pycache__/digraph.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/__pycache__/filters.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/__pycache__/function.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/__pycache__/graph.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/__pycache__/graphviews.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/__pycache__/multidigraph.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/__pycache__/multigraph.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/__pycache__/reportviews.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/historical_tests.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/test_digraph_historical.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/test_function.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/test_multidigraph.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/test_multigraph.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/classes/tests/test_coreviews.py +362 -0
- venv/lib/python3.10/site-packages/networkx/classes/tests/test_filters.py +177 -0
- venv/lib/python3.10/site-packages/networkx/classes/tests/test_function.py +787 -0
- venv/lib/python3.10/site-packages/networkx/generators/__init__.py +33 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/atlas.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/classic.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/cographs.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/degree_seq.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/directed.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/duplication.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/ego.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/expanders.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/harary_graph.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/intersection.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/interval_graph.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/joint_degree_seq.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/lattice.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/line.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/mycielski.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/nonisomorphic_trees.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/random_clustered.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/small.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/social.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/spectral_graph_forge.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/stochastic.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/sudoku.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/networkx/generators/__pycache__/time_series.cpython-310.pyc +0 -0
ckpts/universal/global_step80/zero/10.mlp.dense_h_to_4h.weight/exp_avg_sq.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bf301191a5195e414196ecded5d82a107b0857af6b94395ad45d9637ecf7bb01
|
3 |
+
size 33555627
|
ckpts/universal/global_step80/zero/17.attention.dense.weight/exp_avg.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0a5ca77f9cf5fa803cd4face5d8ab3752f09c8d5bd9ce31e262230a7146b2bf3
|
3 |
+
size 16778396
|
ckpts/universal/global_step80/zero/17.attention.dense.weight/exp_avg_sq.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:738e6326b04edf78c8358d06ace4f569889b79f8a0dbdb5f3daa303e5a2f1d0f
|
3 |
+
size 16778411
|
ckpts/universal/global_step80/zero/25.input_layernorm.weight/exp_avg.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7f8ce118ef6ad626f5227ae866cb7731a68fd4cc5207446b8776ebd9d499525c
|
3 |
+
size 9372
|
ckpts/universal/global_step80/zero/25.input_layernorm.weight/exp_avg_sq.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:266bb660e906e718e76fc3305b55474fba11e679a1e9bd81b423e56b8730bd35
|
3 |
+
size 9387
|
ckpts/universal/global_step80/zero/26.input_layernorm.weight/exp_avg.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:84ddffd9019b752a301314c751d68fb39d202bbf8fc3b65d5a7b271e960c7745
|
3 |
+
size 9372
|
venv/lib/python3.10/site-packages/networkx/classes/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (588 Bytes). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/__pycache__/coreviews.cpython-310.pyc
ADDED
Binary file (16.3 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/__pycache__/digraph.cpython-310.pyc
ADDED
Binary file (46.2 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/__pycache__/filters.cpython-310.pyc
ADDED
Binary file (4.72 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/__pycache__/function.cpython-310.pyc
ADDED
Binary file (37.7 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/__pycache__/graph.cpython-310.pyc
ADDED
Binary file (69.6 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/__pycache__/graphviews.cpython-310.pyc
ADDED
Binary file (8.2 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/__pycache__/multidigraph.cpython-310.pyc
ADDED
Binary file (36 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/__pycache__/multigraph.cpython-310.pyc
ADDED
Binary file (46.3 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/__pycache__/reportviews.cpython-310.pyc
ADDED
Binary file (49 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (190 Bytes). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/historical_tests.cpython-310.pyc
ADDED
Binary file (14 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/test_digraph_historical.cpython-310.pyc
ADDED
Binary file (4.89 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/test_function.cpython-310.pyc
ADDED
Binary file (22.3 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/test_multidigraph.cpython-310.pyc
ADDED
Binary file (14.7 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/tests/__pycache__/test_multigraph.cpython-310.pyc
ADDED
Binary file (17.7 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/classes/tests/test_coreviews.py
ADDED
@@ -0,0 +1,362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pickle
|
2 |
+
|
3 |
+
import pytest
|
4 |
+
|
5 |
+
import networkx as nx
|
6 |
+
|
7 |
+
|
8 |
+
class TestAtlasView:
|
9 |
+
# node->data
|
10 |
+
def setup_method(self):
|
11 |
+
self.d = {0: {"color": "blue", "weight": 1.2}, 1: {}, 2: {"color": 1}}
|
12 |
+
self.av = nx.classes.coreviews.AtlasView(self.d)
|
13 |
+
|
14 |
+
def test_pickle(self):
|
15 |
+
view = self.av
|
16 |
+
pview = pickle.loads(pickle.dumps(view, -1))
|
17 |
+
assert view == pview
|
18 |
+
assert view.__slots__ == pview.__slots__
|
19 |
+
pview = pickle.loads(pickle.dumps(view))
|
20 |
+
assert view == pview
|
21 |
+
assert view.__slots__ == pview.__slots__
|
22 |
+
|
23 |
+
def test_len(self):
|
24 |
+
assert len(self.av) == len(self.d)
|
25 |
+
|
26 |
+
def test_iter(self):
|
27 |
+
assert list(self.av) == list(self.d)
|
28 |
+
|
29 |
+
def test_getitem(self):
|
30 |
+
assert self.av[1] is self.d[1]
|
31 |
+
assert self.av[2]["color"] == 1
|
32 |
+
pytest.raises(KeyError, self.av.__getitem__, 3)
|
33 |
+
|
34 |
+
def test_copy(self):
|
35 |
+
avcopy = self.av.copy()
|
36 |
+
assert avcopy[0] == self.av[0]
|
37 |
+
assert avcopy == self.av
|
38 |
+
assert avcopy[0] is not self.av[0]
|
39 |
+
assert avcopy is not self.av
|
40 |
+
avcopy[5] = {}
|
41 |
+
assert avcopy != self.av
|
42 |
+
|
43 |
+
avcopy[0]["ht"] = 4
|
44 |
+
assert avcopy[0] != self.av[0]
|
45 |
+
self.av[0]["ht"] = 4
|
46 |
+
assert avcopy[0] == self.av[0]
|
47 |
+
del self.av[0]["ht"]
|
48 |
+
|
49 |
+
assert not hasattr(self.av, "__setitem__")
|
50 |
+
|
51 |
+
def test_items(self):
|
52 |
+
assert sorted(self.av.items()) == sorted(self.d.items())
|
53 |
+
|
54 |
+
def test_str(self):
|
55 |
+
out = str(self.d)
|
56 |
+
assert str(self.av) == out
|
57 |
+
|
58 |
+
def test_repr(self):
|
59 |
+
out = "AtlasView(" + str(self.d) + ")"
|
60 |
+
assert repr(self.av) == out
|
61 |
+
|
62 |
+
|
63 |
+
class TestAdjacencyView:
|
64 |
+
# node->nbr->data
|
65 |
+
def setup_method(self):
|
66 |
+
dd = {"color": "blue", "weight": 1.2}
|
67 |
+
self.nd = {0: dd, 1: {}, 2: {"color": 1}}
|
68 |
+
self.adj = {3: self.nd, 0: {3: dd}, 1: {}, 2: {3: {"color": 1}}}
|
69 |
+
self.adjview = nx.classes.coreviews.AdjacencyView(self.adj)
|
70 |
+
|
71 |
+
def test_pickle(self):
|
72 |
+
view = self.adjview
|
73 |
+
pview = pickle.loads(pickle.dumps(view, -1))
|
74 |
+
assert view == pview
|
75 |
+
assert view.__slots__ == pview.__slots__
|
76 |
+
|
77 |
+
def test_len(self):
|
78 |
+
assert len(self.adjview) == len(self.adj)
|
79 |
+
|
80 |
+
def test_iter(self):
|
81 |
+
assert list(self.adjview) == list(self.adj)
|
82 |
+
|
83 |
+
def test_getitem(self):
|
84 |
+
assert self.adjview[1] is not self.adj[1]
|
85 |
+
assert self.adjview[3][0] is self.adjview[0][3]
|
86 |
+
assert self.adjview[2][3]["color"] == 1
|
87 |
+
pytest.raises(KeyError, self.adjview.__getitem__, 4)
|
88 |
+
|
89 |
+
def test_copy(self):
|
90 |
+
avcopy = self.adjview.copy()
|
91 |
+
assert avcopy[0] == self.adjview[0]
|
92 |
+
assert avcopy[0] is not self.adjview[0]
|
93 |
+
|
94 |
+
avcopy[2][3]["ht"] = 4
|
95 |
+
assert avcopy[2] != self.adjview[2]
|
96 |
+
self.adjview[2][3]["ht"] = 4
|
97 |
+
assert avcopy[2] == self.adjview[2]
|
98 |
+
del self.adjview[2][3]["ht"]
|
99 |
+
|
100 |
+
assert not hasattr(self.adjview, "__setitem__")
|
101 |
+
|
102 |
+
def test_items(self):
|
103 |
+
view_items = sorted((n, dict(d)) for n, d in self.adjview.items())
|
104 |
+
assert view_items == sorted(self.adj.items())
|
105 |
+
|
106 |
+
def test_str(self):
|
107 |
+
out = str(dict(self.adj))
|
108 |
+
assert str(self.adjview) == out
|
109 |
+
|
110 |
+
def test_repr(self):
|
111 |
+
out = self.adjview.__class__.__name__ + "(" + str(self.adj) + ")"
|
112 |
+
assert repr(self.adjview) == out
|
113 |
+
|
114 |
+
|
115 |
+
class TestMultiAdjacencyView(TestAdjacencyView):
|
116 |
+
# node->nbr->key->data
|
117 |
+
def setup_method(self):
|
118 |
+
dd = {"color": "blue", "weight": 1.2}
|
119 |
+
self.kd = {0: dd, 1: {}, 2: {"color": 1}}
|
120 |
+
self.nd = {3: self.kd, 0: {3: dd}, 1: {0: {}}, 2: {3: {"color": 1}}}
|
121 |
+
self.adj = {3: self.nd, 0: {3: {3: dd}}, 1: {}, 2: {3: {8: {}}}}
|
122 |
+
self.adjview = nx.classes.coreviews.MultiAdjacencyView(self.adj)
|
123 |
+
|
124 |
+
def test_getitem(self):
|
125 |
+
assert self.adjview[1] is not self.adj[1]
|
126 |
+
assert self.adjview[3][0][3] is self.adjview[0][3][3]
|
127 |
+
assert self.adjview[3][2][3]["color"] == 1
|
128 |
+
pytest.raises(KeyError, self.adjview.__getitem__, 4)
|
129 |
+
|
130 |
+
def test_copy(self):
|
131 |
+
avcopy = self.adjview.copy()
|
132 |
+
assert avcopy[0] == self.adjview[0]
|
133 |
+
assert avcopy[0] is not self.adjview[0]
|
134 |
+
|
135 |
+
avcopy[2][3][8]["ht"] = 4
|
136 |
+
assert avcopy[2] != self.adjview[2]
|
137 |
+
self.adjview[2][3][8]["ht"] = 4
|
138 |
+
assert avcopy[2] == self.adjview[2]
|
139 |
+
del self.adjview[2][3][8]["ht"]
|
140 |
+
|
141 |
+
assert not hasattr(self.adjview, "__setitem__")
|
142 |
+
|
143 |
+
|
144 |
+
class TestUnionAtlas:
|
145 |
+
# node->data
|
146 |
+
def setup_method(self):
|
147 |
+
self.s = {0: {"color": "blue", "weight": 1.2}, 1: {}, 2: {"color": 1}}
|
148 |
+
self.p = {3: {"color": "blue", "weight": 1.2}, 4: {}, 2: {"watch": 2}}
|
149 |
+
self.av = nx.classes.coreviews.UnionAtlas(self.s, self.p)
|
150 |
+
|
151 |
+
def test_pickle(self):
|
152 |
+
view = self.av
|
153 |
+
pview = pickle.loads(pickle.dumps(view, -1))
|
154 |
+
assert view == pview
|
155 |
+
assert view.__slots__ == pview.__slots__
|
156 |
+
|
157 |
+
def test_len(self):
|
158 |
+
assert len(self.av) == len(self.s.keys() | self.p.keys()) == 5
|
159 |
+
|
160 |
+
def test_iter(self):
|
161 |
+
assert set(self.av) == set(self.s) | set(self.p)
|
162 |
+
|
163 |
+
def test_getitem(self):
|
164 |
+
assert self.av[0] is self.s[0]
|
165 |
+
assert self.av[4] is self.p[4]
|
166 |
+
assert self.av[2]["color"] == 1
|
167 |
+
pytest.raises(KeyError, self.av[2].__getitem__, "watch")
|
168 |
+
pytest.raises(KeyError, self.av.__getitem__, 8)
|
169 |
+
|
170 |
+
def test_copy(self):
|
171 |
+
avcopy = self.av.copy()
|
172 |
+
assert avcopy[0] == self.av[0]
|
173 |
+
assert avcopy[0] is not self.av[0]
|
174 |
+
assert avcopy is not self.av
|
175 |
+
avcopy[5] = {}
|
176 |
+
assert avcopy != self.av
|
177 |
+
|
178 |
+
avcopy[0]["ht"] = 4
|
179 |
+
assert avcopy[0] != self.av[0]
|
180 |
+
self.av[0]["ht"] = 4
|
181 |
+
assert avcopy[0] == self.av[0]
|
182 |
+
del self.av[0]["ht"]
|
183 |
+
|
184 |
+
assert not hasattr(self.av, "__setitem__")
|
185 |
+
|
186 |
+
def test_items(self):
|
187 |
+
expected = dict(self.p.items())
|
188 |
+
expected.update(self.s)
|
189 |
+
assert sorted(self.av.items()) == sorted(expected.items())
|
190 |
+
|
191 |
+
def test_str(self):
|
192 |
+
out = str(dict(self.av))
|
193 |
+
assert str(self.av) == out
|
194 |
+
|
195 |
+
def test_repr(self):
|
196 |
+
out = f"{self.av.__class__.__name__}({self.s}, {self.p})"
|
197 |
+
assert repr(self.av) == out
|
198 |
+
|
199 |
+
|
200 |
+
class TestUnionAdjacency:
|
201 |
+
# node->nbr->data
|
202 |
+
def setup_method(self):
|
203 |
+
dd = {"color": "blue", "weight": 1.2}
|
204 |
+
self.nd = {0: dd, 1: {}, 2: {"color": 1}}
|
205 |
+
self.s = {3: self.nd, 0: {}, 1: {}, 2: {3: {"color": 1}}}
|
206 |
+
self.p = {3: {}, 0: {3: dd}, 1: {0: {}}, 2: {1: {"color": 1}}}
|
207 |
+
self.adjview = nx.classes.coreviews.UnionAdjacency(self.s, self.p)
|
208 |
+
|
209 |
+
def test_pickle(self):
|
210 |
+
view = self.adjview
|
211 |
+
pview = pickle.loads(pickle.dumps(view, -1))
|
212 |
+
assert view == pview
|
213 |
+
assert view.__slots__ == pview.__slots__
|
214 |
+
|
215 |
+
def test_len(self):
|
216 |
+
assert len(self.adjview) == len(self.s)
|
217 |
+
|
218 |
+
def test_iter(self):
|
219 |
+
assert sorted(self.adjview) == sorted(self.s)
|
220 |
+
|
221 |
+
def test_getitem(self):
|
222 |
+
assert self.adjview[1] is not self.s[1]
|
223 |
+
assert self.adjview[3][0] is self.adjview[0][3]
|
224 |
+
assert self.adjview[2][3]["color"] == 1
|
225 |
+
pytest.raises(KeyError, self.adjview.__getitem__, 4)
|
226 |
+
|
227 |
+
def test_copy(self):
|
228 |
+
avcopy = self.adjview.copy()
|
229 |
+
assert avcopy[0] == self.adjview[0]
|
230 |
+
assert avcopy[0] is not self.adjview[0]
|
231 |
+
|
232 |
+
avcopy[2][3]["ht"] = 4
|
233 |
+
assert avcopy[2] != self.adjview[2]
|
234 |
+
self.adjview[2][3]["ht"] = 4
|
235 |
+
assert avcopy[2] == self.adjview[2]
|
236 |
+
del self.adjview[2][3]["ht"]
|
237 |
+
|
238 |
+
assert not hasattr(self.adjview, "__setitem__")
|
239 |
+
|
240 |
+
def test_str(self):
|
241 |
+
out = str(dict(self.adjview))
|
242 |
+
assert str(self.adjview) == out
|
243 |
+
|
244 |
+
def test_repr(self):
|
245 |
+
clsname = self.adjview.__class__.__name__
|
246 |
+
out = f"{clsname}({self.s}, {self.p})"
|
247 |
+
assert repr(self.adjview) == out
|
248 |
+
|
249 |
+
|
250 |
+
class TestUnionMultiInner(TestUnionAdjacency):
|
251 |
+
# nbr->key->data
|
252 |
+
def setup_method(self):
|
253 |
+
dd = {"color": "blue", "weight": 1.2}
|
254 |
+
self.kd = {7: {}, "ekey": {}, 9: {"color": 1}}
|
255 |
+
self.s = {3: self.kd, 0: {7: dd}, 1: {}, 2: {"key": {"color": 1}}}
|
256 |
+
self.p = {3: {}, 0: {3: dd}, 1: {}, 2: {1: {"span": 2}}}
|
257 |
+
self.adjview = nx.classes.coreviews.UnionMultiInner(self.s, self.p)
|
258 |
+
|
259 |
+
def test_len(self):
|
260 |
+
assert len(self.adjview) == len(self.s.keys() | self.p.keys()) == 4
|
261 |
+
|
262 |
+
def test_getitem(self):
|
263 |
+
assert self.adjview[1] is not self.s[1]
|
264 |
+
assert self.adjview[0][7] is self.adjview[0][3]
|
265 |
+
assert self.adjview[2]["key"]["color"] == 1
|
266 |
+
assert self.adjview[2][1]["span"] == 2
|
267 |
+
pytest.raises(KeyError, self.adjview.__getitem__, 4)
|
268 |
+
pytest.raises(KeyError, self.adjview[1].__getitem__, "key")
|
269 |
+
|
270 |
+
def test_copy(self):
|
271 |
+
avcopy = self.adjview.copy()
|
272 |
+
assert avcopy[0] == self.adjview[0]
|
273 |
+
assert avcopy[0] is not self.adjview[0]
|
274 |
+
|
275 |
+
avcopy[2][1]["width"] = 8
|
276 |
+
assert avcopy[2] != self.adjview[2]
|
277 |
+
self.adjview[2][1]["width"] = 8
|
278 |
+
assert avcopy[2] == self.adjview[2]
|
279 |
+
del self.adjview[2][1]["width"]
|
280 |
+
|
281 |
+
assert not hasattr(self.adjview, "__setitem__")
|
282 |
+
assert hasattr(avcopy, "__setitem__")
|
283 |
+
|
284 |
+
|
285 |
+
class TestUnionMultiAdjacency(TestUnionAdjacency):
|
286 |
+
# node->nbr->key->data
|
287 |
+
def setup_method(self):
|
288 |
+
dd = {"color": "blue", "weight": 1.2}
|
289 |
+
self.kd = {7: {}, 8: {}, 9: {"color": 1}}
|
290 |
+
self.nd = {3: self.kd, 0: {9: dd}, 1: {8: {}}, 2: {9: {"color": 1}}}
|
291 |
+
self.s = {3: self.nd, 0: {3: {7: dd}}, 1: {}, 2: {3: {8: {}}}}
|
292 |
+
self.p = {3: {}, 0: {3: {9: dd}}, 1: {}, 2: {1: {8: {}}}}
|
293 |
+
self.adjview = nx.classes.coreviews.UnionMultiAdjacency(self.s, self.p)
|
294 |
+
|
295 |
+
def test_getitem(self):
|
296 |
+
assert self.adjview[1] is not self.s[1]
|
297 |
+
assert self.adjview[3][0][9] is self.adjview[0][3][9]
|
298 |
+
assert self.adjview[3][2][9]["color"] == 1
|
299 |
+
pytest.raises(KeyError, self.adjview.__getitem__, 4)
|
300 |
+
|
301 |
+
def test_copy(self):
|
302 |
+
avcopy = self.adjview.copy()
|
303 |
+
assert avcopy[0] == self.adjview[0]
|
304 |
+
assert avcopy[0] is not self.adjview[0]
|
305 |
+
|
306 |
+
avcopy[2][3][8]["ht"] = 4
|
307 |
+
assert avcopy[2] != self.adjview[2]
|
308 |
+
self.adjview[2][3][8]["ht"] = 4
|
309 |
+
assert avcopy[2] == self.adjview[2]
|
310 |
+
del self.adjview[2][3][8]["ht"]
|
311 |
+
|
312 |
+
assert not hasattr(self.adjview, "__setitem__")
|
313 |
+
assert hasattr(avcopy, "__setitem__")
|
314 |
+
|
315 |
+
|
316 |
+
class TestFilteredGraphs:
|
317 |
+
def setup_method(self):
|
318 |
+
self.Graphs = [nx.Graph, nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph]
|
319 |
+
|
320 |
+
def test_hide_show_nodes(self):
|
321 |
+
SubGraph = nx.subgraph_view
|
322 |
+
for Graph in self.Graphs:
|
323 |
+
G = nx.path_graph(4, Graph)
|
324 |
+
SG = G.subgraph([2, 3])
|
325 |
+
RG = SubGraph(G, filter_node=nx.filters.hide_nodes([0, 1]))
|
326 |
+
assert SG.nodes == RG.nodes
|
327 |
+
assert SG.edges == RG.edges
|
328 |
+
SGC = SG.copy()
|
329 |
+
RGC = RG.copy()
|
330 |
+
assert SGC.nodes == RGC.nodes
|
331 |
+
assert SGC.edges == RGC.edges
|
332 |
+
|
333 |
+
def test_str_repr(self):
|
334 |
+
SubGraph = nx.subgraph_view
|
335 |
+
for Graph in self.Graphs:
|
336 |
+
G = nx.path_graph(4, Graph)
|
337 |
+
SG = G.subgraph([2, 3])
|
338 |
+
RG = SubGraph(G, filter_node=nx.filters.hide_nodes([0, 1]))
|
339 |
+
str(SG.adj)
|
340 |
+
str(RG.adj)
|
341 |
+
repr(SG.adj)
|
342 |
+
repr(RG.adj)
|
343 |
+
str(SG.adj[2])
|
344 |
+
str(RG.adj[2])
|
345 |
+
repr(SG.adj[2])
|
346 |
+
repr(RG.adj[2])
|
347 |
+
|
348 |
+
def test_copy(self):
|
349 |
+
SubGraph = nx.subgraph_view
|
350 |
+
for Graph in self.Graphs:
|
351 |
+
G = nx.path_graph(4, Graph)
|
352 |
+
SG = G.subgraph([2, 3])
|
353 |
+
RG = SubGraph(G, filter_node=nx.filters.hide_nodes([0, 1]))
|
354 |
+
RsG = SubGraph(G, filter_node=nx.filters.show_nodes([2, 3]))
|
355 |
+
assert G.adj.copy() == G.adj
|
356 |
+
assert G.adj[2].copy() == G.adj[2]
|
357 |
+
assert SG.adj.copy() == SG.adj
|
358 |
+
assert SG.adj[2].copy() == SG.adj[2]
|
359 |
+
assert RG.adj.copy() == RG.adj
|
360 |
+
assert RG.adj[2].copy() == RG.adj[2]
|
361 |
+
assert RsG.adj.copy() == RsG.adj
|
362 |
+
assert RsG.adj[2].copy() == RsG.adj[2]
|
venv/lib/python3.10/site-packages/networkx/classes/tests/test_filters.py
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pytest
|
2 |
+
|
3 |
+
import networkx as nx
|
4 |
+
|
5 |
+
|
6 |
+
class TestFilterFactory:
|
7 |
+
def test_no_filter(self):
|
8 |
+
nf = nx.filters.no_filter
|
9 |
+
assert nf()
|
10 |
+
assert nf(1)
|
11 |
+
assert nf(2, 1)
|
12 |
+
|
13 |
+
def test_hide_nodes(self):
|
14 |
+
f = nx.classes.filters.hide_nodes([1, 2, 3])
|
15 |
+
assert not f(1)
|
16 |
+
assert not f(2)
|
17 |
+
assert not f(3)
|
18 |
+
assert f(4)
|
19 |
+
assert f(0)
|
20 |
+
assert f("a")
|
21 |
+
pytest.raises(TypeError, f, 1, 2)
|
22 |
+
pytest.raises(TypeError, f)
|
23 |
+
|
24 |
+
def test_show_nodes(self):
|
25 |
+
f = nx.classes.filters.show_nodes([1, 2, 3])
|
26 |
+
assert f(1)
|
27 |
+
assert f(2)
|
28 |
+
assert f(3)
|
29 |
+
assert not f(4)
|
30 |
+
assert not f(0)
|
31 |
+
assert not f("a")
|
32 |
+
pytest.raises(TypeError, f, 1, 2)
|
33 |
+
pytest.raises(TypeError, f)
|
34 |
+
|
35 |
+
def test_hide_edges(self):
|
36 |
+
factory = nx.classes.filters.hide_edges
|
37 |
+
f = factory([(1, 2), (3, 4)])
|
38 |
+
assert not f(1, 2)
|
39 |
+
assert not f(3, 4)
|
40 |
+
assert not f(4, 3)
|
41 |
+
assert f(2, 3)
|
42 |
+
assert f(0, -1)
|
43 |
+
assert f("a", "b")
|
44 |
+
pytest.raises(TypeError, f, 1, 2, 3)
|
45 |
+
pytest.raises(TypeError, f, 1)
|
46 |
+
pytest.raises(TypeError, f)
|
47 |
+
pytest.raises(TypeError, factory, [1, 2, 3])
|
48 |
+
pytest.raises(ValueError, factory, [(1, 2, 3)])
|
49 |
+
|
50 |
+
def test_show_edges(self):
|
51 |
+
factory = nx.classes.filters.show_edges
|
52 |
+
f = factory([(1, 2), (3, 4)])
|
53 |
+
assert f(1, 2)
|
54 |
+
assert f(3, 4)
|
55 |
+
assert f(4, 3)
|
56 |
+
assert not f(2, 3)
|
57 |
+
assert not f(0, -1)
|
58 |
+
assert not f("a", "b")
|
59 |
+
pytest.raises(TypeError, f, 1, 2, 3)
|
60 |
+
pytest.raises(TypeError, f, 1)
|
61 |
+
pytest.raises(TypeError, f)
|
62 |
+
pytest.raises(TypeError, factory, [1, 2, 3])
|
63 |
+
pytest.raises(ValueError, factory, [(1, 2, 3)])
|
64 |
+
|
65 |
+
def test_hide_diedges(self):
|
66 |
+
factory = nx.classes.filters.hide_diedges
|
67 |
+
f = factory([(1, 2), (3, 4)])
|
68 |
+
assert not f(1, 2)
|
69 |
+
assert not f(3, 4)
|
70 |
+
assert f(4, 3)
|
71 |
+
assert f(2, 3)
|
72 |
+
assert f(0, -1)
|
73 |
+
assert f("a", "b")
|
74 |
+
pytest.raises(TypeError, f, 1, 2, 3)
|
75 |
+
pytest.raises(TypeError, f, 1)
|
76 |
+
pytest.raises(TypeError, f)
|
77 |
+
pytest.raises(TypeError, factory, [1, 2, 3])
|
78 |
+
pytest.raises(ValueError, factory, [(1, 2, 3)])
|
79 |
+
|
80 |
+
def test_show_diedges(self):
|
81 |
+
factory = nx.classes.filters.show_diedges
|
82 |
+
f = factory([(1, 2), (3, 4)])
|
83 |
+
assert f(1, 2)
|
84 |
+
assert f(3, 4)
|
85 |
+
assert not f(4, 3)
|
86 |
+
assert not f(2, 3)
|
87 |
+
assert not f(0, -1)
|
88 |
+
assert not f("a", "b")
|
89 |
+
pytest.raises(TypeError, f, 1, 2, 3)
|
90 |
+
pytest.raises(TypeError, f, 1)
|
91 |
+
pytest.raises(TypeError, f)
|
92 |
+
pytest.raises(TypeError, factory, [1, 2, 3])
|
93 |
+
pytest.raises(ValueError, factory, [(1, 2, 3)])
|
94 |
+
|
95 |
+
def test_hide_multiedges(self):
|
96 |
+
factory = nx.classes.filters.hide_multiedges
|
97 |
+
f = factory([(1, 2, 0), (3, 4, 1), (1, 2, 1)])
|
98 |
+
assert not f(1, 2, 0)
|
99 |
+
assert not f(1, 2, 1)
|
100 |
+
assert f(1, 2, 2)
|
101 |
+
assert f(3, 4, 0)
|
102 |
+
assert not f(3, 4, 1)
|
103 |
+
assert not f(4, 3, 1)
|
104 |
+
assert f(4, 3, 0)
|
105 |
+
assert f(2, 3, 0)
|
106 |
+
assert f(0, -1, 0)
|
107 |
+
assert f("a", "b", 0)
|
108 |
+
pytest.raises(TypeError, f, 1, 2, 3, 4)
|
109 |
+
pytest.raises(TypeError, f, 1, 2)
|
110 |
+
pytest.raises(TypeError, f, 1)
|
111 |
+
pytest.raises(TypeError, f)
|
112 |
+
pytest.raises(TypeError, factory, [1, 2, 3])
|
113 |
+
pytest.raises(ValueError, factory, [(1, 2)])
|
114 |
+
pytest.raises(ValueError, factory, [(1, 2, 3, 4)])
|
115 |
+
|
116 |
+
def test_show_multiedges(self):
|
117 |
+
factory = nx.classes.filters.show_multiedges
|
118 |
+
f = factory([(1, 2, 0), (3, 4, 1), (1, 2, 1)])
|
119 |
+
assert f(1, 2, 0)
|
120 |
+
assert f(1, 2, 1)
|
121 |
+
assert not f(1, 2, 2)
|
122 |
+
assert not f(3, 4, 0)
|
123 |
+
assert f(3, 4, 1)
|
124 |
+
assert f(4, 3, 1)
|
125 |
+
assert not f(4, 3, 0)
|
126 |
+
assert not f(2, 3, 0)
|
127 |
+
assert not f(0, -1, 0)
|
128 |
+
assert not f("a", "b", 0)
|
129 |
+
pytest.raises(TypeError, f, 1, 2, 3, 4)
|
130 |
+
pytest.raises(TypeError, f, 1, 2)
|
131 |
+
pytest.raises(TypeError, f, 1)
|
132 |
+
pytest.raises(TypeError, f)
|
133 |
+
pytest.raises(TypeError, factory, [1, 2, 3])
|
134 |
+
pytest.raises(ValueError, factory, [(1, 2)])
|
135 |
+
pytest.raises(ValueError, factory, [(1, 2, 3, 4)])
|
136 |
+
|
137 |
+
def test_hide_multidiedges(self):
|
138 |
+
factory = nx.classes.filters.hide_multidiedges
|
139 |
+
f = factory([(1, 2, 0), (3, 4, 1), (1, 2, 1)])
|
140 |
+
assert not f(1, 2, 0)
|
141 |
+
assert not f(1, 2, 1)
|
142 |
+
assert f(1, 2, 2)
|
143 |
+
assert f(3, 4, 0)
|
144 |
+
assert not f(3, 4, 1)
|
145 |
+
assert f(4, 3, 1)
|
146 |
+
assert f(4, 3, 0)
|
147 |
+
assert f(2, 3, 0)
|
148 |
+
assert f(0, -1, 0)
|
149 |
+
assert f("a", "b", 0)
|
150 |
+
pytest.raises(TypeError, f, 1, 2, 3, 4)
|
151 |
+
pytest.raises(TypeError, f, 1, 2)
|
152 |
+
pytest.raises(TypeError, f, 1)
|
153 |
+
pytest.raises(TypeError, f)
|
154 |
+
pytest.raises(TypeError, factory, [1, 2, 3])
|
155 |
+
pytest.raises(ValueError, factory, [(1, 2)])
|
156 |
+
pytest.raises(ValueError, factory, [(1, 2, 3, 4)])
|
157 |
+
|
158 |
+
def test_show_multidiedges(self):
|
159 |
+
factory = nx.classes.filters.show_multidiedges
|
160 |
+
f = factory([(1, 2, 0), (3, 4, 1), (1, 2, 1)])
|
161 |
+
assert f(1, 2, 0)
|
162 |
+
assert f(1, 2, 1)
|
163 |
+
assert not f(1, 2, 2)
|
164 |
+
assert not f(3, 4, 0)
|
165 |
+
assert f(3, 4, 1)
|
166 |
+
assert not f(4, 3, 1)
|
167 |
+
assert not f(4, 3, 0)
|
168 |
+
assert not f(2, 3, 0)
|
169 |
+
assert not f(0, -1, 0)
|
170 |
+
assert not f("a", "b", 0)
|
171 |
+
pytest.raises(TypeError, f, 1, 2, 3, 4)
|
172 |
+
pytest.raises(TypeError, f, 1, 2)
|
173 |
+
pytest.raises(TypeError, f, 1)
|
174 |
+
pytest.raises(TypeError, f)
|
175 |
+
pytest.raises(TypeError, factory, [1, 2, 3])
|
176 |
+
pytest.raises(ValueError, factory, [(1, 2)])
|
177 |
+
pytest.raises(ValueError, factory, [(1, 2, 3, 4)])
|
venv/lib/python3.10/site-packages/networkx/classes/tests/test_function.py
ADDED
@@ -0,0 +1,787 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
|
3 |
+
import pytest
|
4 |
+
|
5 |
+
import networkx as nx
|
6 |
+
from networkx.utils import edges_equal, nodes_equal
|
7 |
+
|
8 |
+
|
9 |
+
def test_degree_histogram_empty():
|
10 |
+
G = nx.Graph()
|
11 |
+
assert nx.degree_histogram(G) == []
|
12 |
+
|
13 |
+
|
14 |
+
class TestFunction:
|
15 |
+
def setup_method(self):
|
16 |
+
self.G = nx.Graph({0: [1, 2, 3], 1: [1, 2, 0], 4: []}, name="Test")
|
17 |
+
self.Gdegree = {0: 3, 1: 2, 2: 2, 3: 1, 4: 0}
|
18 |
+
self.Gnodes = list(range(5))
|
19 |
+
self.Gedges = [(0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2)]
|
20 |
+
self.DG = nx.DiGraph({0: [1, 2, 3], 1: [1, 2, 0], 4: []})
|
21 |
+
self.DGin_degree = {0: 1, 1: 2, 2: 2, 3: 1, 4: 0}
|
22 |
+
self.DGout_degree = {0: 3, 1: 3, 2: 0, 3: 0, 4: 0}
|
23 |
+
self.DGnodes = list(range(5))
|
24 |
+
self.DGedges = [(0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2)]
|
25 |
+
|
26 |
+
def test_nodes(self):
|
27 |
+
assert nodes_equal(self.G.nodes(), list(nx.nodes(self.G)))
|
28 |
+
assert nodes_equal(self.DG.nodes(), list(nx.nodes(self.DG)))
|
29 |
+
|
30 |
+
def test_edges(self):
|
31 |
+
assert edges_equal(self.G.edges(), list(nx.edges(self.G)))
|
32 |
+
assert sorted(self.DG.edges()) == sorted(nx.edges(self.DG))
|
33 |
+
assert edges_equal(
|
34 |
+
self.G.edges(nbunch=[0, 1, 3]), list(nx.edges(self.G, nbunch=[0, 1, 3]))
|
35 |
+
)
|
36 |
+
assert sorted(self.DG.edges(nbunch=[0, 1, 3])) == sorted(
|
37 |
+
nx.edges(self.DG, nbunch=[0, 1, 3])
|
38 |
+
)
|
39 |
+
|
40 |
+
def test_degree(self):
|
41 |
+
assert edges_equal(self.G.degree(), list(nx.degree(self.G)))
|
42 |
+
assert sorted(self.DG.degree()) == sorted(nx.degree(self.DG))
|
43 |
+
assert edges_equal(
|
44 |
+
self.G.degree(nbunch=[0, 1]), list(nx.degree(self.G, nbunch=[0, 1]))
|
45 |
+
)
|
46 |
+
assert sorted(self.DG.degree(nbunch=[0, 1])) == sorted(
|
47 |
+
nx.degree(self.DG, nbunch=[0, 1])
|
48 |
+
)
|
49 |
+
assert edges_equal(
|
50 |
+
self.G.degree(weight="weight"), list(nx.degree(self.G, weight="weight"))
|
51 |
+
)
|
52 |
+
assert sorted(self.DG.degree(weight="weight")) == sorted(
|
53 |
+
nx.degree(self.DG, weight="weight")
|
54 |
+
)
|
55 |
+
|
56 |
+
def test_neighbors(self):
|
57 |
+
assert list(self.G.neighbors(1)) == list(nx.neighbors(self.G, 1))
|
58 |
+
assert list(self.DG.neighbors(1)) == list(nx.neighbors(self.DG, 1))
|
59 |
+
|
60 |
+
def test_number_of_nodes(self):
|
61 |
+
assert self.G.number_of_nodes() == nx.number_of_nodes(self.G)
|
62 |
+
assert self.DG.number_of_nodes() == nx.number_of_nodes(self.DG)
|
63 |
+
|
64 |
+
def test_number_of_edges(self):
|
65 |
+
assert self.G.number_of_edges() == nx.number_of_edges(self.G)
|
66 |
+
assert self.DG.number_of_edges() == nx.number_of_edges(self.DG)
|
67 |
+
|
68 |
+
def test_is_directed(self):
|
69 |
+
assert self.G.is_directed() == nx.is_directed(self.G)
|
70 |
+
assert self.DG.is_directed() == nx.is_directed(self.DG)
|
71 |
+
|
72 |
+
def test_add_star(self):
|
73 |
+
G = self.G.copy()
|
74 |
+
nlist = [12, 13, 14, 15]
|
75 |
+
nx.add_star(G, nlist)
|
76 |
+
assert edges_equal(G.edges(nlist), [(12, 13), (12, 14), (12, 15)])
|
77 |
+
|
78 |
+
G = self.G.copy()
|
79 |
+
nx.add_star(G, nlist, weight=2.0)
|
80 |
+
assert edges_equal(
|
81 |
+
G.edges(nlist, data=True),
|
82 |
+
[
|
83 |
+
(12, 13, {"weight": 2.0}),
|
84 |
+
(12, 14, {"weight": 2.0}),
|
85 |
+
(12, 15, {"weight": 2.0}),
|
86 |
+
],
|
87 |
+
)
|
88 |
+
|
89 |
+
G = self.G.copy()
|
90 |
+
nlist = [12]
|
91 |
+
nx.add_star(G, nlist)
|
92 |
+
assert nodes_equal(G, list(self.G) + nlist)
|
93 |
+
|
94 |
+
G = self.G.copy()
|
95 |
+
nlist = []
|
96 |
+
nx.add_star(G, nlist)
|
97 |
+
assert nodes_equal(G.nodes, self.Gnodes)
|
98 |
+
assert edges_equal(G.edges, self.G.edges)
|
99 |
+
|
100 |
+
def test_add_path(self):
|
101 |
+
G = self.G.copy()
|
102 |
+
nlist = [12, 13, 14, 15]
|
103 |
+
nx.add_path(G, nlist)
|
104 |
+
assert edges_equal(G.edges(nlist), [(12, 13), (13, 14), (14, 15)])
|
105 |
+
G = self.G.copy()
|
106 |
+
nx.add_path(G, nlist, weight=2.0)
|
107 |
+
assert edges_equal(
|
108 |
+
G.edges(nlist, data=True),
|
109 |
+
[
|
110 |
+
(12, 13, {"weight": 2.0}),
|
111 |
+
(13, 14, {"weight": 2.0}),
|
112 |
+
(14, 15, {"weight": 2.0}),
|
113 |
+
],
|
114 |
+
)
|
115 |
+
|
116 |
+
G = self.G.copy()
|
117 |
+
nlist = ["node"]
|
118 |
+
nx.add_path(G, nlist)
|
119 |
+
assert edges_equal(G.edges(nlist), [])
|
120 |
+
assert nodes_equal(G, list(self.G) + ["node"])
|
121 |
+
|
122 |
+
G = self.G.copy()
|
123 |
+
nlist = iter(["node"])
|
124 |
+
nx.add_path(G, nlist)
|
125 |
+
assert edges_equal(G.edges(["node"]), [])
|
126 |
+
assert nodes_equal(G, list(self.G) + ["node"])
|
127 |
+
|
128 |
+
G = self.G.copy()
|
129 |
+
nlist = [12]
|
130 |
+
nx.add_path(G, nlist)
|
131 |
+
assert edges_equal(G.edges(nlist), [])
|
132 |
+
assert nodes_equal(G, list(self.G) + [12])
|
133 |
+
|
134 |
+
G = self.G.copy()
|
135 |
+
nlist = iter([12])
|
136 |
+
nx.add_path(G, nlist)
|
137 |
+
assert edges_equal(G.edges([12]), [])
|
138 |
+
assert nodes_equal(G, list(self.G) + [12])
|
139 |
+
|
140 |
+
G = self.G.copy()
|
141 |
+
nlist = []
|
142 |
+
nx.add_path(G, nlist)
|
143 |
+
assert edges_equal(G.edges, self.G.edges)
|
144 |
+
assert nodes_equal(G, list(self.G))
|
145 |
+
|
146 |
+
G = self.G.copy()
|
147 |
+
nlist = iter([])
|
148 |
+
nx.add_path(G, nlist)
|
149 |
+
assert edges_equal(G.edges, self.G.edges)
|
150 |
+
assert nodes_equal(G, list(self.G))
|
151 |
+
|
152 |
+
def test_add_cycle(self):
|
153 |
+
G = self.G.copy()
|
154 |
+
nlist = [12, 13, 14, 15]
|
155 |
+
oklists = [
|
156 |
+
[(12, 13), (12, 15), (13, 14), (14, 15)],
|
157 |
+
[(12, 13), (13, 14), (14, 15), (15, 12)],
|
158 |
+
]
|
159 |
+
nx.add_cycle(G, nlist)
|
160 |
+
assert sorted(G.edges(nlist)) in oklists
|
161 |
+
G = self.G.copy()
|
162 |
+
oklists = [
|
163 |
+
[
|
164 |
+
(12, 13, {"weight": 1.0}),
|
165 |
+
(12, 15, {"weight": 1.0}),
|
166 |
+
(13, 14, {"weight": 1.0}),
|
167 |
+
(14, 15, {"weight": 1.0}),
|
168 |
+
],
|
169 |
+
[
|
170 |
+
(12, 13, {"weight": 1.0}),
|
171 |
+
(13, 14, {"weight": 1.0}),
|
172 |
+
(14, 15, {"weight": 1.0}),
|
173 |
+
(15, 12, {"weight": 1.0}),
|
174 |
+
],
|
175 |
+
]
|
176 |
+
nx.add_cycle(G, nlist, weight=1.0)
|
177 |
+
assert sorted(G.edges(nlist, data=True)) in oklists
|
178 |
+
|
179 |
+
G = self.G.copy()
|
180 |
+
nlist = [12]
|
181 |
+
nx.add_cycle(G, nlist)
|
182 |
+
assert nodes_equal(G, list(self.G) + nlist)
|
183 |
+
|
184 |
+
G = self.G.copy()
|
185 |
+
nlist = []
|
186 |
+
nx.add_cycle(G, nlist)
|
187 |
+
assert nodes_equal(G.nodes, self.Gnodes)
|
188 |
+
assert edges_equal(G.edges, self.G.edges)
|
189 |
+
|
190 |
+
def test_subgraph(self):
|
191 |
+
assert (
|
192 |
+
self.G.subgraph([0, 1, 2, 4]).adj == nx.subgraph(self.G, [0, 1, 2, 4]).adj
|
193 |
+
)
|
194 |
+
assert (
|
195 |
+
self.DG.subgraph([0, 1, 2, 4]).adj == nx.subgraph(self.DG, [0, 1, 2, 4]).adj
|
196 |
+
)
|
197 |
+
assert (
|
198 |
+
self.G.subgraph([0, 1, 2, 4]).adj
|
199 |
+
== nx.induced_subgraph(self.G, [0, 1, 2, 4]).adj
|
200 |
+
)
|
201 |
+
assert (
|
202 |
+
self.DG.subgraph([0, 1, 2, 4]).adj
|
203 |
+
== nx.induced_subgraph(self.DG, [0, 1, 2, 4]).adj
|
204 |
+
)
|
205 |
+
# subgraph-subgraph chain is allowed in function interface
|
206 |
+
H = nx.induced_subgraph(self.G.subgraph([0, 1, 2, 4]), [0, 1, 4])
|
207 |
+
assert H._graph is not self.G
|
208 |
+
assert H.adj == self.G.subgraph([0, 1, 4]).adj
|
209 |
+
|
210 |
+
def test_edge_subgraph(self):
|
211 |
+
assert (
|
212 |
+
self.G.edge_subgraph([(1, 2), (0, 3)]).adj
|
213 |
+
== nx.edge_subgraph(self.G, [(1, 2), (0, 3)]).adj
|
214 |
+
)
|
215 |
+
assert (
|
216 |
+
self.DG.edge_subgraph([(1, 2), (0, 3)]).adj
|
217 |
+
== nx.edge_subgraph(self.DG, [(1, 2), (0, 3)]).adj
|
218 |
+
)
|
219 |
+
|
220 |
+
def test_create_empty_copy(self):
|
221 |
+
G = nx.create_empty_copy(self.G, with_data=False)
|
222 |
+
assert nodes_equal(G, list(self.G))
|
223 |
+
assert G.graph == {}
|
224 |
+
assert G._node == {}.fromkeys(self.G.nodes(), {})
|
225 |
+
assert G._adj == {}.fromkeys(self.G.nodes(), {})
|
226 |
+
G = nx.create_empty_copy(self.G)
|
227 |
+
assert nodes_equal(G, list(self.G))
|
228 |
+
assert G.graph == self.G.graph
|
229 |
+
assert G._node == self.G._node
|
230 |
+
assert G._adj == {}.fromkeys(self.G.nodes(), {})
|
231 |
+
|
232 |
+
def test_degree_histogram(self):
|
233 |
+
assert nx.degree_histogram(self.G) == [1, 1, 1, 1, 1]
|
234 |
+
|
235 |
+
def test_density(self):
|
236 |
+
assert nx.density(self.G) == 0.5
|
237 |
+
assert nx.density(self.DG) == 0.3
|
238 |
+
G = nx.Graph()
|
239 |
+
G.add_node(1)
|
240 |
+
assert nx.density(G) == 0.0
|
241 |
+
|
242 |
+
def test_density_selfloop(self):
|
243 |
+
G = nx.Graph()
|
244 |
+
G.add_edge(1, 1)
|
245 |
+
assert nx.density(G) == 0.0
|
246 |
+
G.add_edge(1, 2)
|
247 |
+
assert nx.density(G) == 2.0
|
248 |
+
|
249 |
+
def test_freeze(self):
|
250 |
+
G = nx.freeze(self.G)
|
251 |
+
assert G.frozen
|
252 |
+
pytest.raises(nx.NetworkXError, G.add_node, 1)
|
253 |
+
pytest.raises(nx.NetworkXError, G.add_nodes_from, [1])
|
254 |
+
pytest.raises(nx.NetworkXError, G.remove_node, 1)
|
255 |
+
pytest.raises(nx.NetworkXError, G.remove_nodes_from, [1])
|
256 |
+
pytest.raises(nx.NetworkXError, G.add_edge, 1, 2)
|
257 |
+
pytest.raises(nx.NetworkXError, G.add_edges_from, [(1, 2)])
|
258 |
+
pytest.raises(nx.NetworkXError, G.remove_edge, 1, 2)
|
259 |
+
pytest.raises(nx.NetworkXError, G.remove_edges_from, [(1, 2)])
|
260 |
+
pytest.raises(nx.NetworkXError, G.clear_edges)
|
261 |
+
pytest.raises(nx.NetworkXError, G.clear)
|
262 |
+
|
263 |
+
def test_is_frozen(self):
|
264 |
+
assert not nx.is_frozen(self.G)
|
265 |
+
G = nx.freeze(self.G)
|
266 |
+
assert G.frozen == nx.is_frozen(self.G)
|
267 |
+
assert G.frozen
|
268 |
+
|
269 |
+
def test_node_attributes_are_still_mutable_on_frozen_graph(self):
|
270 |
+
G = nx.freeze(nx.path_graph(3))
|
271 |
+
node = G.nodes[0]
|
272 |
+
node["node_attribute"] = True
|
273 |
+
assert node["node_attribute"] == True
|
274 |
+
|
275 |
+
def test_edge_attributes_are_still_mutable_on_frozen_graph(self):
|
276 |
+
G = nx.freeze(nx.path_graph(3))
|
277 |
+
edge = G.edges[(0, 1)]
|
278 |
+
edge["edge_attribute"] = True
|
279 |
+
assert edge["edge_attribute"] == True
|
280 |
+
|
281 |
+
def test_neighbors_complete_graph(self):
|
282 |
+
graph = nx.complete_graph(100)
|
283 |
+
pop = random.sample(list(graph), 1)
|
284 |
+
nbors = list(nx.neighbors(graph, pop[0]))
|
285 |
+
# should be all the other vertices in the graph
|
286 |
+
assert len(nbors) == len(graph) - 1
|
287 |
+
|
288 |
+
graph = nx.path_graph(100)
|
289 |
+
node = random.sample(list(graph), 1)[0]
|
290 |
+
nbors = list(nx.neighbors(graph, node))
|
291 |
+
# should be all the other vertices in the graph
|
292 |
+
if node != 0 and node != 99:
|
293 |
+
assert len(nbors) == 2
|
294 |
+
else:
|
295 |
+
assert len(nbors) == 1
|
296 |
+
|
297 |
+
# create a star graph with 99 outer nodes
|
298 |
+
graph = nx.star_graph(99)
|
299 |
+
nbors = list(nx.neighbors(graph, 0))
|
300 |
+
assert len(nbors) == 99
|
301 |
+
|
302 |
+
def test_non_neighbors(self):
|
303 |
+
graph = nx.complete_graph(100)
|
304 |
+
pop = random.sample(list(graph), 1)
|
305 |
+
nbors = nx.non_neighbors(graph, pop[0])
|
306 |
+
# should be all the other vertices in the graph
|
307 |
+
assert len(nbors) == 0
|
308 |
+
|
309 |
+
graph = nx.path_graph(100)
|
310 |
+
node = random.sample(list(graph), 1)[0]
|
311 |
+
nbors = nx.non_neighbors(graph, node)
|
312 |
+
# should be all the other vertices in the graph
|
313 |
+
if node != 0 and node != 99:
|
314 |
+
assert len(nbors) == 97
|
315 |
+
else:
|
316 |
+
assert len(nbors) == 98
|
317 |
+
|
318 |
+
# create a star graph with 99 outer nodes
|
319 |
+
graph = nx.star_graph(99)
|
320 |
+
nbors = nx.non_neighbors(graph, 0)
|
321 |
+
assert len(nbors) == 0
|
322 |
+
|
323 |
+
# disconnected graph
|
324 |
+
graph = nx.Graph()
|
325 |
+
graph.add_nodes_from(range(10))
|
326 |
+
nbors = nx.non_neighbors(graph, 0)
|
327 |
+
assert len(nbors) == 9
|
328 |
+
|
329 |
+
def test_non_edges(self):
|
330 |
+
# All possible edges exist
|
331 |
+
graph = nx.complete_graph(5)
|
332 |
+
nedges = list(nx.non_edges(graph))
|
333 |
+
assert len(nedges) == 0
|
334 |
+
|
335 |
+
graph = nx.path_graph(4)
|
336 |
+
expected = [(0, 2), (0, 3), (1, 3)]
|
337 |
+
nedges = list(nx.non_edges(graph))
|
338 |
+
for u, v in expected:
|
339 |
+
assert (u, v) in nedges or (v, u) in nedges
|
340 |
+
|
341 |
+
graph = nx.star_graph(4)
|
342 |
+
expected = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
343 |
+
nedges = list(nx.non_edges(graph))
|
344 |
+
for u, v in expected:
|
345 |
+
assert (u, v) in nedges or (v, u) in nedges
|
346 |
+
|
347 |
+
# Directed graphs
|
348 |
+
graph = nx.DiGraph()
|
349 |
+
graph.add_edges_from([(0, 2), (2, 0), (2, 1)])
|
350 |
+
expected = [(0, 1), (1, 0), (1, 2)]
|
351 |
+
nedges = list(nx.non_edges(graph))
|
352 |
+
for e in expected:
|
353 |
+
assert e in nedges
|
354 |
+
|
355 |
+
def test_is_weighted(self):
|
356 |
+
G = nx.Graph()
|
357 |
+
assert not nx.is_weighted(G)
|
358 |
+
|
359 |
+
G = nx.path_graph(4)
|
360 |
+
assert not nx.is_weighted(G)
|
361 |
+
assert not nx.is_weighted(G, (2, 3))
|
362 |
+
|
363 |
+
G.add_node(4)
|
364 |
+
G.add_edge(3, 4, weight=4)
|
365 |
+
assert not nx.is_weighted(G)
|
366 |
+
assert nx.is_weighted(G, (3, 4))
|
367 |
+
|
368 |
+
G = nx.DiGraph()
|
369 |
+
G.add_weighted_edges_from(
|
370 |
+
[
|
371 |
+
("0", "3", 3),
|
372 |
+
("0", "1", -5),
|
373 |
+
("1", "0", -5),
|
374 |
+
("0", "2", 2),
|
375 |
+
("1", "2", 4),
|
376 |
+
("2", "3", 1),
|
377 |
+
]
|
378 |
+
)
|
379 |
+
assert nx.is_weighted(G)
|
380 |
+
assert nx.is_weighted(G, ("1", "0"))
|
381 |
+
|
382 |
+
G = G.to_undirected()
|
383 |
+
assert nx.is_weighted(G)
|
384 |
+
assert nx.is_weighted(G, ("1", "0"))
|
385 |
+
|
386 |
+
pytest.raises(nx.NetworkXError, nx.is_weighted, G, (1, 2))
|
387 |
+
|
388 |
+
def test_is_negatively_weighted(self):
|
389 |
+
G = nx.Graph()
|
390 |
+
assert not nx.is_negatively_weighted(G)
|
391 |
+
|
392 |
+
G.add_node(1)
|
393 |
+
G.add_nodes_from([2, 3, 4, 5])
|
394 |
+
assert not nx.is_negatively_weighted(G)
|
395 |
+
|
396 |
+
G.add_edge(1, 2, weight=4)
|
397 |
+
assert not nx.is_negatively_weighted(G, (1, 2))
|
398 |
+
|
399 |
+
G.add_edges_from([(1, 3), (2, 4), (2, 6)])
|
400 |
+
G[1][3]["color"] = "blue"
|
401 |
+
assert not nx.is_negatively_weighted(G)
|
402 |
+
assert not nx.is_negatively_weighted(G, (1, 3))
|
403 |
+
|
404 |
+
G[2][4]["weight"] = -2
|
405 |
+
assert nx.is_negatively_weighted(G, (2, 4))
|
406 |
+
assert nx.is_negatively_weighted(G)
|
407 |
+
|
408 |
+
G = nx.DiGraph()
|
409 |
+
G.add_weighted_edges_from(
|
410 |
+
[
|
411 |
+
("0", "3", 3),
|
412 |
+
("0", "1", -5),
|
413 |
+
("1", "0", -2),
|
414 |
+
("0", "2", 2),
|
415 |
+
("1", "2", -3),
|
416 |
+
("2", "3", 1),
|
417 |
+
]
|
418 |
+
)
|
419 |
+
assert nx.is_negatively_weighted(G)
|
420 |
+
assert not nx.is_negatively_weighted(G, ("0", "3"))
|
421 |
+
assert nx.is_negatively_weighted(G, ("1", "0"))
|
422 |
+
|
423 |
+
pytest.raises(nx.NetworkXError, nx.is_negatively_weighted, G, (1, 4))
|
424 |
+
|
425 |
+
|
426 |
+
class TestCommonNeighbors:
|
427 |
+
@classmethod
|
428 |
+
def setup_class(cls):
|
429 |
+
cls.func = staticmethod(nx.common_neighbors)
|
430 |
+
|
431 |
+
def test_func(G, u, v, expected):
|
432 |
+
result = sorted(cls.func(G, u, v))
|
433 |
+
assert result == expected
|
434 |
+
|
435 |
+
cls.test = staticmethod(test_func)
|
436 |
+
|
437 |
+
def test_K5(self):
|
438 |
+
G = nx.complete_graph(5)
|
439 |
+
self.test(G, 0, 1, [2, 3, 4])
|
440 |
+
|
441 |
+
def test_P3(self):
|
442 |
+
G = nx.path_graph(3)
|
443 |
+
self.test(G, 0, 2, [1])
|
444 |
+
|
445 |
+
def test_S4(self):
|
446 |
+
G = nx.star_graph(4)
|
447 |
+
self.test(G, 1, 2, [0])
|
448 |
+
|
449 |
+
def test_digraph(self):
|
450 |
+
with pytest.raises(nx.NetworkXNotImplemented):
|
451 |
+
G = nx.DiGraph()
|
452 |
+
G.add_edges_from([(0, 1), (1, 2)])
|
453 |
+
self.func(G, 0, 2)
|
454 |
+
|
455 |
+
def test_nonexistent_nodes(self):
|
456 |
+
G = nx.complete_graph(5)
|
457 |
+
pytest.raises(nx.NetworkXError, nx.common_neighbors, G, 5, 4)
|
458 |
+
pytest.raises(nx.NetworkXError, nx.common_neighbors, G, 4, 5)
|
459 |
+
pytest.raises(nx.NetworkXError, nx.common_neighbors, G, 5, 6)
|
460 |
+
|
461 |
+
def test_custom1(self):
|
462 |
+
"""Case of no common neighbors."""
|
463 |
+
G = nx.Graph()
|
464 |
+
G.add_nodes_from([0, 1])
|
465 |
+
self.test(G, 0, 1, [])
|
466 |
+
|
467 |
+
def test_custom2(self):
|
468 |
+
"""Case of equal nodes."""
|
469 |
+
G = nx.complete_graph(4)
|
470 |
+
self.test(G, 0, 0, [1, 2, 3])
|
471 |
+
|
472 |
+
|
473 |
+
@pytest.mark.parametrize(
|
474 |
+
"graph_type", (nx.Graph, nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph)
|
475 |
+
)
|
476 |
+
def test_set_node_attributes(graph_type):
|
477 |
+
# Test single value
|
478 |
+
G = nx.path_graph(3, create_using=graph_type)
|
479 |
+
vals = 100
|
480 |
+
attr = "hello"
|
481 |
+
nx.set_node_attributes(G, vals, attr)
|
482 |
+
assert G.nodes[0][attr] == vals
|
483 |
+
assert G.nodes[1][attr] == vals
|
484 |
+
assert G.nodes[2][attr] == vals
|
485 |
+
|
486 |
+
# Test dictionary
|
487 |
+
G = nx.path_graph(3, create_using=graph_type)
|
488 |
+
vals = dict(zip(sorted(G.nodes()), range(len(G))))
|
489 |
+
attr = "hi"
|
490 |
+
nx.set_node_attributes(G, vals, attr)
|
491 |
+
assert G.nodes[0][attr] == 0
|
492 |
+
assert G.nodes[1][attr] == 1
|
493 |
+
assert G.nodes[2][attr] == 2
|
494 |
+
|
495 |
+
# Test dictionary of dictionaries
|
496 |
+
G = nx.path_graph(3, create_using=graph_type)
|
497 |
+
d = {"hi": 0, "hello": 200}
|
498 |
+
vals = dict.fromkeys(G.nodes(), d)
|
499 |
+
vals.pop(0)
|
500 |
+
nx.set_node_attributes(G, vals)
|
501 |
+
assert G.nodes[0] == {}
|
502 |
+
assert G.nodes[1]["hi"] == 0
|
503 |
+
assert G.nodes[2]["hello"] == 200
|
504 |
+
|
505 |
+
|
506 |
+
@pytest.mark.parametrize(
|
507 |
+
("values", "name"),
|
508 |
+
(
|
509 |
+
({0: "red", 1: "blue"}, "color"), # values dictionary
|
510 |
+
({0: {"color": "red"}, 1: {"color": "blue"}}, None), # dict-of-dict
|
511 |
+
),
|
512 |
+
)
|
513 |
+
def test_set_node_attributes_ignores_extra_nodes(values, name):
|
514 |
+
"""
|
515 |
+
When `values` is a dict or dict-of-dict keyed by nodes, ensure that keys
|
516 |
+
that correspond to nodes not in G are ignored.
|
517 |
+
"""
|
518 |
+
G = nx.Graph()
|
519 |
+
G.add_node(0)
|
520 |
+
nx.set_node_attributes(G, values, name)
|
521 |
+
assert G.nodes[0]["color"] == "red"
|
522 |
+
assert 1 not in G.nodes
|
523 |
+
|
524 |
+
|
525 |
+
@pytest.mark.parametrize("graph_type", (nx.Graph, nx.DiGraph))
|
526 |
+
def test_set_edge_attributes(graph_type):
|
527 |
+
# Test single value
|
528 |
+
G = nx.path_graph(3, create_using=graph_type)
|
529 |
+
attr = "hello"
|
530 |
+
vals = 3
|
531 |
+
nx.set_edge_attributes(G, vals, attr)
|
532 |
+
assert G[0][1][attr] == vals
|
533 |
+
assert G[1][2][attr] == vals
|
534 |
+
|
535 |
+
# Test multiple values
|
536 |
+
G = nx.path_graph(3, create_using=graph_type)
|
537 |
+
attr = "hi"
|
538 |
+
edges = [(0, 1), (1, 2)]
|
539 |
+
vals = dict(zip(edges, range(len(edges))))
|
540 |
+
nx.set_edge_attributes(G, vals, attr)
|
541 |
+
assert G[0][1][attr] == 0
|
542 |
+
assert G[1][2][attr] == 1
|
543 |
+
|
544 |
+
# Test dictionary of dictionaries
|
545 |
+
G = nx.path_graph(3, create_using=graph_type)
|
546 |
+
d = {"hi": 0, "hello": 200}
|
547 |
+
edges = [(0, 1)]
|
548 |
+
vals = dict.fromkeys(edges, d)
|
549 |
+
nx.set_edge_attributes(G, vals)
|
550 |
+
assert G[0][1]["hi"] == 0
|
551 |
+
assert G[0][1]["hello"] == 200
|
552 |
+
assert G[1][2] == {}
|
553 |
+
|
554 |
+
|
555 |
+
@pytest.mark.parametrize(
|
556 |
+
("values", "name"),
|
557 |
+
(
|
558 |
+
({(0, 1): 1.0, (0, 2): 2.0}, "weight"), # values dict
|
559 |
+
({(0, 1): {"weight": 1.0}, (0, 2): {"weight": 2.0}}, None), # values dod
|
560 |
+
),
|
561 |
+
)
|
562 |
+
def test_set_edge_attributes_ignores_extra_edges(values, name):
|
563 |
+
"""If `values` is a dict or dict-of-dicts containing edges that are not in
|
564 |
+
G, data associate with these edges should be ignored.
|
565 |
+
"""
|
566 |
+
G = nx.Graph([(0, 1)])
|
567 |
+
nx.set_edge_attributes(G, values, name)
|
568 |
+
assert G[0][1]["weight"] == 1.0
|
569 |
+
assert (0, 2) not in G.edges
|
570 |
+
|
571 |
+
|
572 |
+
@pytest.mark.parametrize("graph_type", (nx.MultiGraph, nx.MultiDiGraph))
|
573 |
+
def test_set_edge_attributes_multi(graph_type):
|
574 |
+
# Test single value
|
575 |
+
G = nx.path_graph(3, create_using=graph_type)
|
576 |
+
attr = "hello"
|
577 |
+
vals = 3
|
578 |
+
nx.set_edge_attributes(G, vals, attr)
|
579 |
+
assert G[0][1][0][attr] == vals
|
580 |
+
assert G[1][2][0][attr] == vals
|
581 |
+
|
582 |
+
# Test multiple values
|
583 |
+
G = nx.path_graph(3, create_using=graph_type)
|
584 |
+
attr = "hi"
|
585 |
+
edges = [(0, 1, 0), (1, 2, 0)]
|
586 |
+
vals = dict(zip(edges, range(len(edges))))
|
587 |
+
nx.set_edge_attributes(G, vals, attr)
|
588 |
+
assert G[0][1][0][attr] == 0
|
589 |
+
assert G[1][2][0][attr] == 1
|
590 |
+
|
591 |
+
# Test dictionary of dictionaries
|
592 |
+
G = nx.path_graph(3, create_using=graph_type)
|
593 |
+
d = {"hi": 0, "hello": 200}
|
594 |
+
edges = [(0, 1, 0)]
|
595 |
+
vals = dict.fromkeys(edges, d)
|
596 |
+
nx.set_edge_attributes(G, vals)
|
597 |
+
assert G[0][1][0]["hi"] == 0
|
598 |
+
assert G[0][1][0]["hello"] == 200
|
599 |
+
assert G[1][2][0] == {}
|
600 |
+
|
601 |
+
|
602 |
+
@pytest.mark.parametrize(
|
603 |
+
("values", "name"),
|
604 |
+
(
|
605 |
+
({(0, 1, 0): 1.0, (0, 2, 0): 2.0}, "weight"), # values dict
|
606 |
+
({(0, 1, 0): {"weight": 1.0}, (0, 2, 0): {"weight": 2.0}}, None), # values dod
|
607 |
+
),
|
608 |
+
)
|
609 |
+
def test_set_edge_attributes_multi_ignores_extra_edges(values, name):
|
610 |
+
"""If `values` is a dict or dict-of-dicts containing edges that are not in
|
611 |
+
G, data associate with these edges should be ignored.
|
612 |
+
"""
|
613 |
+
G = nx.MultiGraph([(0, 1, 0), (0, 1, 1)])
|
614 |
+
nx.set_edge_attributes(G, values, name)
|
615 |
+
assert G[0][1][0]["weight"] == 1.0
|
616 |
+
assert G[0][1][1] == {}
|
617 |
+
assert (0, 2) not in G.edges()
|
618 |
+
|
619 |
+
|
620 |
+
def test_get_node_attributes():
|
621 |
+
graphs = [nx.Graph(), nx.DiGraph(), nx.MultiGraph(), nx.MultiDiGraph()]
|
622 |
+
for G in graphs:
|
623 |
+
G = nx.path_graph(3, create_using=G)
|
624 |
+
attr = "hello"
|
625 |
+
vals = 100
|
626 |
+
nx.set_node_attributes(G, vals, attr)
|
627 |
+
attrs = nx.get_node_attributes(G, attr)
|
628 |
+
assert attrs[0] == vals
|
629 |
+
assert attrs[1] == vals
|
630 |
+
assert attrs[2] == vals
|
631 |
+
default_val = 1
|
632 |
+
G.add_node(4)
|
633 |
+
attrs = nx.get_node_attributes(G, attr, default=default_val)
|
634 |
+
assert attrs[4] == default_val
|
635 |
+
|
636 |
+
|
637 |
+
def test_get_edge_attributes():
|
638 |
+
graphs = [nx.Graph(), nx.DiGraph(), nx.MultiGraph(), nx.MultiDiGraph()]
|
639 |
+
for G in graphs:
|
640 |
+
G = nx.path_graph(3, create_using=G)
|
641 |
+
attr = "hello"
|
642 |
+
vals = 100
|
643 |
+
nx.set_edge_attributes(G, vals, attr)
|
644 |
+
attrs = nx.get_edge_attributes(G, attr)
|
645 |
+
assert len(attrs) == 2
|
646 |
+
|
647 |
+
for edge in G.edges:
|
648 |
+
assert attrs[edge] == vals
|
649 |
+
|
650 |
+
default_val = vals
|
651 |
+
G.add_edge(4, 5)
|
652 |
+
deafult_attrs = nx.get_edge_attributes(G, attr, default=default_val)
|
653 |
+
assert len(deafult_attrs) == 3
|
654 |
+
|
655 |
+
for edge in G.edges:
|
656 |
+
assert deafult_attrs[edge] == vals
|
657 |
+
|
658 |
+
|
659 |
+
def test_is_empty():
|
660 |
+
graphs = [nx.Graph(), nx.DiGraph(), nx.MultiGraph(), nx.MultiDiGraph()]
|
661 |
+
for G in graphs:
|
662 |
+
assert nx.is_empty(G)
|
663 |
+
G.add_nodes_from(range(5))
|
664 |
+
assert nx.is_empty(G)
|
665 |
+
G.add_edges_from([(1, 2), (3, 4)])
|
666 |
+
assert not nx.is_empty(G)
|
667 |
+
|
668 |
+
|
669 |
+
@pytest.mark.parametrize(
|
670 |
+
"graph_type", [nx.Graph, nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph]
|
671 |
+
)
|
672 |
+
def test_selfloops(graph_type):
|
673 |
+
G = nx.complete_graph(3, create_using=graph_type)
|
674 |
+
G.add_edge(0, 0)
|
675 |
+
assert nodes_equal(nx.nodes_with_selfloops(G), [0])
|
676 |
+
assert edges_equal(nx.selfloop_edges(G), [(0, 0)])
|
677 |
+
assert edges_equal(nx.selfloop_edges(G, data=True), [(0, 0, {})])
|
678 |
+
assert nx.number_of_selfloops(G) == 1
|
679 |
+
|
680 |
+
|
681 |
+
@pytest.mark.parametrize(
|
682 |
+
"graph_type", [nx.Graph, nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph]
|
683 |
+
)
|
684 |
+
def test_selfloop_edges_attr(graph_type):
|
685 |
+
G = nx.complete_graph(3, create_using=graph_type)
|
686 |
+
G.add_edge(0, 0)
|
687 |
+
G.add_edge(1, 1, weight=2)
|
688 |
+
assert edges_equal(
|
689 |
+
nx.selfloop_edges(G, data=True), [(0, 0, {}), (1, 1, {"weight": 2})]
|
690 |
+
)
|
691 |
+
assert edges_equal(nx.selfloop_edges(G, data="weight"), [(0, 0, None), (1, 1, 2)])
|
692 |
+
|
693 |
+
|
694 |
+
def test_selfloop_edges_multi_with_data_and_keys():
|
695 |
+
G = nx.complete_graph(3, create_using=nx.MultiGraph)
|
696 |
+
G.add_edge(0, 0, weight=10)
|
697 |
+
G.add_edge(0, 0, weight=100)
|
698 |
+
assert edges_equal(
|
699 |
+
nx.selfloop_edges(G, data="weight", keys=True), [(0, 0, 0, 10), (0, 0, 1, 100)]
|
700 |
+
)
|
701 |
+
|
702 |
+
|
703 |
+
@pytest.mark.parametrize("graph_type", [nx.Graph, nx.DiGraph])
|
704 |
+
def test_selfloops_removal(graph_type):
|
705 |
+
G = nx.complete_graph(3, create_using=graph_type)
|
706 |
+
G.add_edge(0, 0)
|
707 |
+
G.remove_edges_from(nx.selfloop_edges(G, keys=True))
|
708 |
+
G.add_edge(0, 0)
|
709 |
+
G.remove_edges_from(nx.selfloop_edges(G, data=True))
|
710 |
+
G.add_edge(0, 0)
|
711 |
+
G.remove_edges_from(nx.selfloop_edges(G, keys=True, data=True))
|
712 |
+
|
713 |
+
|
714 |
+
@pytest.mark.parametrize("graph_type", [nx.MultiGraph, nx.MultiDiGraph])
|
715 |
+
def test_selfloops_removal_multi(graph_type):
|
716 |
+
"""test removing selfloops behavior vis-a-vis altering a dict while iterating.
|
717 |
+
cf. gh-4068"""
|
718 |
+
G = nx.complete_graph(3, create_using=graph_type)
|
719 |
+
# Defaults - see gh-4080
|
720 |
+
G.add_edge(0, 0)
|
721 |
+
G.add_edge(0, 0)
|
722 |
+
G.remove_edges_from(nx.selfloop_edges(G))
|
723 |
+
assert (0, 0) not in G.edges()
|
724 |
+
# With keys
|
725 |
+
G.add_edge(0, 0)
|
726 |
+
G.add_edge(0, 0)
|
727 |
+
with pytest.raises(RuntimeError):
|
728 |
+
G.remove_edges_from(nx.selfloop_edges(G, keys=True))
|
729 |
+
# With data
|
730 |
+
G.add_edge(0, 0)
|
731 |
+
G.add_edge(0, 0)
|
732 |
+
with pytest.raises(TypeError):
|
733 |
+
G.remove_edges_from(nx.selfloop_edges(G, data=True))
|
734 |
+
# With keys and data
|
735 |
+
G.add_edge(0, 0)
|
736 |
+
G.add_edge(0, 0)
|
737 |
+
with pytest.raises(RuntimeError):
|
738 |
+
G.remove_edges_from(nx.selfloop_edges(G, data=True, keys=True))
|
739 |
+
|
740 |
+
|
741 |
+
def test_pathweight():
|
742 |
+
valid_path = [1, 2, 3]
|
743 |
+
invalid_path = [1, 3, 2]
|
744 |
+
graphs = [nx.Graph(), nx.DiGraph(), nx.MultiGraph(), nx.MultiDiGraph()]
|
745 |
+
edges = [
|
746 |
+
(1, 2, {"cost": 5, "dist": 6}),
|
747 |
+
(2, 3, {"cost": 3, "dist": 4}),
|
748 |
+
(1, 2, {"cost": 1, "dist": 2}),
|
749 |
+
]
|
750 |
+
for graph in graphs:
|
751 |
+
graph.add_edges_from(edges)
|
752 |
+
assert nx.path_weight(graph, valid_path, "cost") == 4
|
753 |
+
assert nx.path_weight(graph, valid_path, "dist") == 6
|
754 |
+
pytest.raises(nx.NetworkXNoPath, nx.path_weight, graph, invalid_path, "cost")
|
755 |
+
|
756 |
+
|
757 |
+
@pytest.mark.parametrize(
|
758 |
+
"G", (nx.Graph(), nx.DiGraph(), nx.MultiGraph(), nx.MultiDiGraph())
|
759 |
+
)
|
760 |
+
def test_ispath(G):
|
761 |
+
G.add_edges_from([(1, 2), (2, 3), (1, 2), (3, 4)])
|
762 |
+
valid_path = [1, 2, 3, 4]
|
763 |
+
invalid_path = [1, 2, 4, 3] # wrong node order
|
764 |
+
another_invalid_path = [1, 2, 3, 4, 5] # contains node not in G
|
765 |
+
assert nx.is_path(G, valid_path)
|
766 |
+
assert not nx.is_path(G, invalid_path)
|
767 |
+
assert not nx.is_path(G, another_invalid_path)
|
768 |
+
|
769 |
+
|
770 |
+
@pytest.mark.parametrize("G", (nx.Graph(), nx.DiGraph()))
|
771 |
+
def test_restricted_view(G):
|
772 |
+
G.add_edges_from([(0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2)])
|
773 |
+
G.add_node(4)
|
774 |
+
H = nx.restricted_view(G, [0, 2, 5], [(1, 2), (3, 4)])
|
775 |
+
assert set(H.nodes()) == {1, 3, 4}
|
776 |
+
assert set(H.edges()) == {(1, 1)}
|
777 |
+
|
778 |
+
|
779 |
+
@pytest.mark.parametrize("G", (nx.MultiGraph(), nx.MultiDiGraph()))
|
780 |
+
def test_restricted_view_multi(G):
|
781 |
+
G.add_edges_from(
|
782 |
+
[(0, 1, 0), (0, 2, 0), (0, 3, 0), (0, 1, 1), (1, 0, 0), (1, 1, 0), (1, 2, 0)]
|
783 |
+
)
|
784 |
+
G.add_node(4)
|
785 |
+
H = nx.restricted_view(G, [0, 2, 5], [(1, 2, 0), (3, 4, 0)])
|
786 |
+
assert set(H.nodes()) == {1, 3, 4}
|
787 |
+
assert set(H.edges()) == {(1, 1)}
|
venv/lib/python3.10/site-packages/networkx/generators/__init__.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
A package for generating various graphs in networkx.
|
3 |
+
|
4 |
+
"""
|
5 |
+
from networkx.generators.atlas import *
|
6 |
+
from networkx.generators.classic import *
|
7 |
+
from networkx.generators.cographs import *
|
8 |
+
from networkx.generators.community import *
|
9 |
+
from networkx.generators.degree_seq import *
|
10 |
+
from networkx.generators.directed import *
|
11 |
+
from networkx.generators.duplication import *
|
12 |
+
from networkx.generators.ego import *
|
13 |
+
from networkx.generators.expanders import *
|
14 |
+
from networkx.generators.geometric import *
|
15 |
+
from networkx.generators.harary_graph import *
|
16 |
+
from networkx.generators.internet_as_graphs import *
|
17 |
+
from networkx.generators.intersection import *
|
18 |
+
from networkx.generators.interval_graph import *
|
19 |
+
from networkx.generators.joint_degree_seq import *
|
20 |
+
from networkx.generators.lattice import *
|
21 |
+
from networkx.generators.line import *
|
22 |
+
from networkx.generators.mycielski import *
|
23 |
+
from networkx.generators.nonisomorphic_trees import *
|
24 |
+
from networkx.generators.random_clustered import *
|
25 |
+
from networkx.generators.random_graphs import *
|
26 |
+
from networkx.generators.small import *
|
27 |
+
from networkx.generators.social import *
|
28 |
+
from networkx.generators.spectral_graph_forge import *
|
29 |
+
from networkx.generators.stochastic import *
|
30 |
+
from networkx.generators.sudoku import *
|
31 |
+
from networkx.generators.time_series import *
|
32 |
+
from networkx.generators.trees import *
|
33 |
+
from networkx.generators.triads import *
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (1.48 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/atlas.cpython-310.pyc
ADDED
Binary file (4.33 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/classic.cpython-310.pyc
ADDED
Binary file (29.4 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/cographs.cpython-310.pyc
ADDED
Binary file (2.24 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/degree_seq.cpython-310.pyc
ADDED
Binary file (25.7 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/directed.cpython-310.pyc
ADDED
Binary file (15 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/duplication.cpython-310.pyc
ADDED
Binary file (4.42 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/ego.cpython-310.pyc
ADDED
Binary file (1.82 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/expanders.cpython-310.pyc
ADDED
Binary file (12.4 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/harary_graph.cpython-310.pyc
ADDED
Binary file (4.81 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/intersection.cpython-310.pyc
ADDED
Binary file (4.27 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/interval_graph.cpython-310.pyc
ADDED
Binary file (2.34 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/joint_degree_seq.cpython-310.pyc
ADDED
Binary file (17.2 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/lattice.cpython-310.pyc
ADDED
Binary file (15 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/line.cpython-310.pyc
ADDED
Binary file (15.3 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/mycielski.cpython-310.pyc
ADDED
Binary file (3.86 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/nonisomorphic_trees.cpython-310.pyc
ADDED
Binary file (5.66 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/random_clustered.cpython-310.pyc
ADDED
Binary file (4.14 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/small.cpython-310.pyc
ADDED
Binary file (26.4 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/social.cpython-310.pyc
ADDED
Binary file (12.9 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/spectral_graph_forge.cpython-310.pyc
ADDED
Binary file (4.24 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/stochastic.cpython-310.pyc
ADDED
Binary file (2.01 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/sudoku.cpython-310.pyc
ADDED
Binary file (4.05 kB). View file
|
|
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/time_series.cpython-310.pyc
ADDED
Binary file (2.61 kB). View file
|
|