summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/applications/plot_circuits.py1
-rw-r--r--examples/drawing/plot_lanl_routes.py1
-rw-r--r--examples/drawing/plot_unix_email.py1
-rw-r--r--examples/graph/plot_roget.py1
-rw-r--r--examples/javascript/force.py2
-rw-r--r--examples/subclass/plot_printgraph.py1
-rw-r--r--networkx/algorithms/approximation/tests/test_approx_clust_coeff.py8
-rw-r--r--networkx/algorithms/approximation/tests/test_connectivity.py8
-rw-r--r--networkx/algorithms/approximation/tests/test_kcomponents.py4
-rw-r--r--networkx/algorithms/assortativity/tests/test_mixing.py1
-rw-r--r--networkx/algorithms/bipartite/tests/test_centrality.py3
-rw-r--r--networkx/algorithms/bipartite/tests/test_covering.py2
-rw-r--r--networkx/algorithms/bipartite/tests/test_generators.py26
-rw-r--r--networkx/algorithms/centrality/tests/test_betweenness_centrality.py3
-rw-r--r--networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py55
-rw-r--r--networkx/algorithms/centrality/tests/test_closeness_centrality.py4
-rw-r--r--networkx/algorithms/centrality/tests/test_current_flow_closeness.py1
-rw-r--r--networkx/algorithms/centrality/tests/test_degree_centrality.py1
-rw-r--r--networkx/algorithms/centrality/tests/test_eigenvector_centrality.py5
-rw-r--r--networkx/algorithms/centrality/tests/test_harmonic_centrality.py3
-rw-r--r--networkx/algorithms/centrality/tests/test_katz_centrality.py1
-rw-r--r--networkx/algorithms/centrality/tests/test_load_centrality.py3
-rw-r--r--networkx/algorithms/centrality/tests/test_percolation_centrality.py1
-rw-r--r--networkx/algorithms/centrality/tests/test_reaching.py1
-rw-r--r--networkx/algorithms/centrality/tests/test_subgraph.py1
-rw-r--r--networkx/algorithms/coloring/tests/test_coloring.py2
-rw-r--r--networkx/algorithms/community/label_propagation.py2
-rw-r--r--networkx/algorithms/community/tests/test_label_propagation.py2
-rw-r--r--networkx/algorithms/community/tests/test_quality.py1
-rw-r--r--networkx/algorithms/components/tests/test_attracting.py2
-rw-r--r--networkx/algorithms/components/tests/test_semiconnected.py1
-rw-r--r--networkx/algorithms/connectivity/tests/test_connectivity.py16
-rw-r--r--networkx/algorithms/connectivity/tests/test_edge_augmentation.py4
-rw-r--r--networkx/algorithms/connectivity/tests/test_stoer_wagner.py1
-rw-r--r--networkx/algorithms/flow/tests/test_gomory_hu.py12
-rw-r--r--networkx/algorithms/flow/tests/test_maxflow.py6
-rw-r--r--networkx/algorithms/flow/tests/test_maxflow_large_graph.py2
-rw-r--r--networkx/algorithms/flow/tests/test_mincost.py2
-rw-r--r--networkx/algorithms/isomorphism/tests/test_ismags.py18
-rw-r--r--networkx/algorithms/isomorphism/tests/test_isomorphvf2.py18
-rw-r--r--networkx/algorithms/isomorphism/tests/test_vf2userfunc.py2
-rw-r--r--networkx/algorithms/link_analysis/tests/test_hits.py4
-rw-r--r--networkx/algorithms/link_analysis/tests/test_pagerank.py10
-rw-r--r--networkx/algorithms/operators/tests/test_all.py14
-rw-r--r--networkx/algorithms/operators/tests/test_binary.py36
-rw-r--r--networkx/algorithms/operators/tests/test_product.py18
-rw-r--r--networkx/algorithms/operators/tests/test_unary.py6
-rw-r--r--networkx/algorithms/shortest_paths/tests/test_dense.py24
-rw-r--r--networkx/algorithms/shortest_paths/tests/test_generic.py62
-rw-r--r--networkx/algorithms/shortest_paths/tests/test_unweighted.py6
-rw-r--r--networkx/algorithms/shortest_paths/tests/test_weighted.py86
-rw-r--r--networkx/algorithms/similarity.py13
-rw-r--r--networkx/algorithms/tests/test_boundary.py6
-rw-r--r--networkx/algorithms/tests/test_chordal.py2
-rw-r--r--networkx/algorithms/tests/test_clique.py42
-rw-r--r--networkx/algorithms/tests/test_cluster.py62
-rw-r--r--networkx/algorithms/tests/test_core.py8
-rw-r--r--networkx/algorithms/tests/test_cycles.py2
-rw-r--r--networkx/algorithms/tests/test_dag.py20
-rw-r--r--networkx/algorithms/tests/test_distance_measures.py14
-rw-r--r--networkx/algorithms/tests/test_dominance.py54
-rw-r--r--networkx/algorithms/tests/test_link_prediction.py28
-rw-r--r--networkx/algorithms/tests/test_lowest_common_ancestors.py74
-rw-r--r--networkx/algorithms/tests/test_mis.py4
-rw-r--r--networkx/algorithms/tests/test_moral.py1
-rw-r--r--networkx/algorithms/tests/test_planar_drawing.py2
-rw-r--r--networkx/algorithms/tests/test_richclub.py40
-rw-r--r--networkx/algorithms/tests/test_similarity.py16
-rw-r--r--networkx/algorithms/tests/test_simple_paths.py12
-rw-r--r--networkx/algorithms/tests/test_swap.py2
-rw-r--r--networkx/algorithms/tests/test_threshold.py24
-rw-r--r--networkx/algorithms/traversal/tests/test_bfs.py16
-rw-r--r--networkx/algorithms/traversal/tests/test_dfs.py26
-rw-r--r--networkx/algorithms/tree/tests/test_branchings.py8
-rw-r--r--networkx/classes/tests/test_digraph_historical.py6
-rw-r--r--networkx/classes/tests/test_function.py18
-rw-r--r--networkx/classes/tests/test_graph.py14
-rw-r--r--networkx/classes/tests/test_graphviews.py8
-rw-r--r--networkx/classes/tests/test_multidigraph.py88
-rw-r--r--networkx/classes/tests/test_multigraph.py30
-rw-r--r--networkx/classes/tests/test_subgraphviews.py6
-rw-r--r--networkx/convert_matrix.py4
-rw-r--r--networkx/drawing/tests/test_layout.py1
-rw-r--r--networkx/drawing/tests/test_pydot.py1
-rw-r--r--networkx/drawing/tests/test_pylab.py4
-rw-r--r--networkx/generators/tests/test_classic.py10
-rw-r--r--networkx/generators/tests/test_cographs.py2
-rw-r--r--networkx/generators/tests/test_community.py2
-rw-r--r--networkx/generators/tests/test_degree_seq.py6
-rw-r--r--networkx/generators/tests/test_lattice.py2
-rw-r--r--networkx/generators/tests/test_line.py4
-rw-r--r--networkx/generators/tests/test_random_graphs.py6
-rw-r--r--networkx/generators/tests/test_small.py4
-rw-r--r--networkx/generators/tests/test_stochastic.py8
-rw-r--r--networkx/linalg/tests/test_algebraic_connectivity.py1
-rw-r--r--networkx/linalg/tests/test_bethehessian.py10
-rw-r--r--networkx/linalg/tests/test_graphmatrix.py42
-rw-r--r--networkx/linalg/tests/test_laplacian.py14
-rw-r--r--networkx/linalg/tests/test_modularity.py6
-rw-r--r--networkx/linalg/tests/test_spectrum.py3
-rw-r--r--networkx/readwrite/nx_shp.py1
-rw-r--r--networkx/readwrite/tests/test_edgelist.py7
-rw-r--r--networkx/readwrite/tests/test_gexf.py28
-rw-r--r--networkx/readwrite/tests/test_gml.py26
-rw-r--r--networkx/readwrite/tests/test_graph6.py4
-rw-r--r--networkx/readwrite/tests/test_graphml.py29
-rw-r--r--networkx/readwrite/tests/test_leda.py16
-rw-r--r--networkx/readwrite/tests/test_pajek.py8
-rw-r--r--networkx/tests/test_all_random_functions.py2
-rw-r--r--networkx/tests/test_convert.py4
-rw-r--r--networkx/tests/test_convert_numpy.py1
-rw-r--r--networkx/tests/test_relabel.py4
-rw-r--r--networkx/utils/tests/test_decorators.py3
-rw-r--r--networkx/utils/tests/test_misc.py2
-rw-r--r--networkx/utils/tests/test_rcm.py2
-rw-r--r--networkx/utils/tests/test_unionfind.py1
116 files changed, 716 insertions, 693 deletions
diff --git a/examples/applications/plot_circuits.py b/examples/applications/plot_circuits.py
index e6285fab..9438da69 100644
--- a/examples/applications/plot_circuits.py
+++ b/examples/applications/plot_circuits.py
@@ -96,5 +96,6 @@ def main():
formula = circuit_to_formula(circuit)
print(formula_to_string(formula))
+
if __name__ == '__main__':
main()
diff --git a/examples/drawing/plot_lanl_routes.py b/examples/drawing/plot_lanl_routes.py
index 6aa616ab..13778591 100644
--- a/examples/drawing/plot_lanl_routes.py
+++ b/examples/drawing/plot_lanl_routes.py
@@ -32,6 +32,7 @@ except ImportError:
raise ImportError("This example needs Graphviz and either "
"PyGraphviz or pydot")
+
def lanl_graph():
""" Return the lanl internet view graph from lanl.edges
"""
diff --git a/examples/drawing/plot_unix_email.py b/examples/drawing/plot_unix_email.py
index 792bd17c..bc8f4990 100644
--- a/examples/drawing/plot_unix_email.py
+++ b/examples/drawing/plot_unix_email.py
@@ -36,6 +36,7 @@ import networkx as nx
# unix mailbox recipe
# see https://docs.python.org/3/library/mailbox.html
+
def mbox_graph():
mbox = mailbox.mbox("unix_email.mbox") # parse unix mailbox
diff --git a/examples/graph/plot_roget.py b/examples/graph/plot_roget.py
index bf359511..07c664d3 100644
--- a/examples/graph/plot_roget.py
+++ b/examples/graph/plot_roget.py
@@ -40,6 +40,7 @@ import sys
import matplotlib.pyplot as plt
from networkx import nx
+
def roget_graph():
""" Return the thesaurus graph from the roget.dat example in
the Stanford Graph Base.
diff --git a/examples/javascript/force.py b/examples/javascript/force.py
index 6fee8c17..0d97e0c9 100644
--- a/examples/javascript/force.py
+++ b/examples/javascript/force.py
@@ -33,9 +33,11 @@ print('Wrote node-link JSON data to force/force.json')
# Serve the file over http to allow for cross origin requests
app = flask.Flask(__name__, static_folder="force")
+
@app.route('/')
def static_proxy():
return app.send_static_file('force.html')
+
print('\nGo to http://localhost:8000 to see the example\n')
app.run(port=8000)
diff --git a/examples/subclass/plot_printgraph.py b/examples/subclass/plot_printgraph.py
index a9ad473c..9d8e1974 100644
--- a/examples/subclass/plot_printgraph.py
+++ b/examples/subclass/plot_printgraph.py
@@ -22,6 +22,7 @@ import matplotlib.pyplot as plt
import networkx as nx
from networkx import Graph
+
class PrintGraph(Graph):
"""
Example subclass of the Graph class.
diff --git a/networkx/algorithms/approximation/tests/test_approx_clust_coeff.py b/networkx/algorithms/approximation/tests/test_approx_clust_coeff.py
index 8bb538dc..c1642c18 100644
--- a/networkx/algorithms/approximation/tests/test_approx_clust_coeff.py
+++ b/networkx/algorithms/approximation/tests/test_approx_clust_coeff.py
@@ -9,28 +9,28 @@ def test_petersen():
# Actual coefficient is 0
G = nx.petersen_graph()
assert (average_clustering(G, trials=int(len(G) / 2)) ==
- nx.average_clustering(G))
+ 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))
+ 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))
+ 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))
+ nx.average_clustering(G))
def test_empty():
diff --git a/networkx/algorithms/approximation/tests/test_connectivity.py b/networkx/algorithms/approximation/tests/test_connectivity.py
index 42cd9a15..d9053541 100644
--- a/networkx/algorithms/approximation/tests/test_connectivity.py
+++ b/networkx/algorithms/approximation/tests/test_connectivity.py
@@ -104,8 +104,8 @@ def test_directed_node_connectivity():
D = nx.cycle_graph(10).to_directed() # 2 reciprocal edges
assert 1 == approx.node_connectivity(G)
assert 1 == approx.node_connectivity(G, 1, 4)
- assert 2 == approx.node_connectivity(D)
- assert 2 == approx.node_connectivity(D, 1, 4)
+ assert 2 == approx.node_connectivity(D)
+ assert 2 == approx.node_connectivity(D, 1, 4)
class TestAllPairsNodeConnectivityApprox:
@@ -122,8 +122,8 @@ class TestAllPairsNodeConnectivityApprox:
cls.K10 = nx.complete_graph(10)
cls.K5 = nx.complete_graph(5)
cls.G_list = [cls.path, cls.directed_path, cls.cycle,
- cls.directed_cycle, cls.gnp, cls.directed_gnp, cls.K10,
- cls.K5, cls.K20]
+ cls.directed_cycle, cls.gnp, cls.directed_gnp, cls.K10,
+ cls.K5, cls.K20]
def test_cycles(self):
K_undir = approx.all_pairs_node_connectivity(self.cycle)
diff --git a/networkx/algorithms/approximation/tests/test_kcomponents.py b/networkx/algorithms/approximation/tests/test_kcomponents.py
index 9a0c5161..c1c65416 100644
--- a/networkx/algorithms/approximation/tests/test_kcomponents.py
+++ b/networkx/algorithms/approximation/tests/test_kcomponents.py
@@ -259,6 +259,6 @@ class TestAntiGraph:
assert sum(d for n, d in G.degree()) == sum(d for n, d in A.degree())
# AntiGraph is a ThinGraph, so all the weights are 1
assert (sum(d for n, d in A.degree()) ==
- sum(d for n, d in A.degree(weight='weight')))
+ sum(d for n, d in A.degree(weight='weight')))
assert (sum(d for n, d in G.degree(nodes)) ==
- sum(d for n, d in A.degree(nodes)))
+ sum(d for n, d in A.degree(nodes)))
diff --git a/networkx/algorithms/assortativity/tests/test_mixing.py b/networkx/algorithms/assortativity/tests/test_mixing.py
index 620236f6..fbaf73b7 100644
--- a/networkx/algorithms/assortativity/tests/test_mixing.py
+++ b/networkx/algorithms/assortativity/tests/test_mixing.py
@@ -43,7 +43,6 @@ class TestDegreeMixingDict(BaseTestDegreeMixing):
class TestDegreeMixingMatrix(BaseTestDegreeMixing):
-
def test_degree_mixing_matrix_undirected(self):
a_result = np.array([[0, 0, 0],
[0, 0, 2],
diff --git a/networkx/algorithms/bipartite/tests/test_centrality.py b/networkx/algorithms/bipartite/tests/test_centrality.py
index 143d5364..3a8d6ac5 100644
--- a/networkx/algorithms/bipartite/tests/test_centrality.py
+++ b/networkx/algorithms/bipartite/tests/test_centrality.py
@@ -2,6 +2,7 @@ import networkx as nx
from networkx.algorithms import bipartite
from networkx.testing import almost_equal
+
class TestBipartiteCentrality(object):
@classmethod
@@ -11,7 +12,7 @@ class TestBipartiteCentrality(object):
cls.C4 = nx.cycle_graph(4)
cls.davis = nx.davis_southern_women_graph()
cls.top_nodes = [n for n, d in cls.davis.nodes(data=True)
- if d['bipartite'] == 0]
+ if d['bipartite'] == 0]
def test_degree_centrality(self):
d = bipartite.degree_centrality(self.P4, [1, 3])
diff --git a/networkx/algorithms/bipartite/tests/test_covering.py b/networkx/algorithms/bipartite/tests/test_covering.py
index 2fd7173b..61b63b86 100644
--- a/networkx/algorithms/bipartite/tests/test_covering.py
+++ b/networkx/algorithms/bipartite/tests/test_covering.py
@@ -19,7 +19,7 @@ class TestMinEdgeCover:
G = nx.Graph()
G.add_edge(0, 1)
assert (bipartite.min_edge_cover(G) ==
- {(0, 1), (1, 0)})
+ {(0, 1), (1, 0)})
def test_bipartite_default(self):
G = nx.Graph()
diff --git a/networkx/algorithms/bipartite/tests/test_generators.py b/networkx/algorithms/bipartite/tests/test_generators.py
index 33a39769..22c77658 100644
--- a/networkx/algorithms/bipartite/tests/test_generators.py
+++ b/networkx/algorithms/bipartite/tests/test_generators.py
@@ -84,13 +84,13 @@ class TestGeneratorsBipartite():
bseq = [2, 2, 2, 2, 2, 2]
G = configuration_model(aseq, bseq)
assert (sorted(d for n, d in G.degree()) ==
- [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
+ [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
aseq = [2, 2, 2, 2, 2, 2]
bseq = [3, 3, 3, 3]
G = configuration_model(aseq, bseq)
assert (sorted(d for n, d in G.degree()) ==
- [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
+ [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
aseq = [2, 2, 2, 1, 1, 1]
bseq = [3, 3, 3]
@@ -98,7 +98,7 @@ class TestGeneratorsBipartite():
assert G.is_multigraph()
assert not G.is_directed()
assert (sorted(d for n, d in G.degree()) ==
- [1, 1, 1, 2, 2, 2, 3, 3, 3])
+ [1, 1, 1, 2, 2, 2, 3, 3, 3])
GU = nx.project(nx.Graph(G), range(len(aseq)))
assert GU.number_of_nodes() == 6
@@ -140,7 +140,7 @@ class TestGeneratorsBipartite():
bseq = [2, 2, 2, 2, 2, 2]
G = havel_hakimi_graph(aseq, bseq)
assert (sorted(d for n, d in G.degree()) ==
- [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
+ [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
aseq = [2, 2, 2, 2, 2, 2]
bseq = [3, 3, 3, 3]
@@ -148,7 +148,7 @@ class TestGeneratorsBipartite():
assert G.is_multigraph()
assert not G.is_directed()
assert (sorted(d for n, d in G.degree()) ==
- [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
+ [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
GU = nx.project(nx.Graph(G), range(len(aseq)))
assert GU.number_of_nodes() == 6
@@ -190,13 +190,13 @@ class TestGeneratorsBipartite():
bseq = [2, 2, 2, 2, 2, 2]
G = reverse_havel_hakimi_graph(aseq, bseq)
assert (sorted(d for n, d in G.degree()) ==
- [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
+ [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
aseq = [2, 2, 2, 2, 2, 2]
bseq = [3, 3, 3, 3]
G = reverse_havel_hakimi_graph(aseq, bseq)
assert (sorted(d for n, d in G.degree()) ==
- [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
+ [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
aseq = [2, 2, 2, 1, 1, 1]
bseq = [3, 3, 3]
@@ -204,7 +204,7 @@ class TestGeneratorsBipartite():
assert G.is_multigraph()
assert not G.is_directed()
assert (sorted(d for n, d in G.degree()) ==
- [1, 1, 1, 2, 2, 2, 3, 3, 3])
+ [1, 1, 1, 2, 2, 2, 3, 3, 3])
GU = nx.project(nx.Graph(G), range(len(aseq)))
assert GU.number_of_nodes() == 6
@@ -246,13 +246,13 @@ class TestGeneratorsBipartite():
bseq = [2, 2, 2, 2, 2, 2]
G = alternating_havel_hakimi_graph(aseq, bseq)
assert (sorted(d for n, d in G.degree()) ==
- [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
+ [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
aseq = [2, 2, 2, 2, 2, 2]
bseq = [3, 3, 3, 3]
G = alternating_havel_hakimi_graph(aseq, bseq)
assert (sorted(d for n, d in G.degree()) ==
- [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
+ [2, 2, 2, 2, 2, 2, 3, 3, 3, 3])
aseq = [2, 2, 2, 1, 1, 1]
bseq = [3, 3, 3]
@@ -260,7 +260,7 @@ class TestGeneratorsBipartite():
assert G.is_multigraph()
assert not G.is_directed()
assert (sorted(d for n, d in G.degree()) ==
- [1, 1, 1, 2, 2, 2, 3, 3, 3])
+ [1, 1, 1, 2, 2, 2, 3, 3, 3])
GU = nx.project(nx.Graph(G), range(len(aseq)))
assert GU.number_of_nodes() == 6
@@ -332,7 +332,7 @@ class TestGeneratorsBipartite():
assert len(G) == n + m
assert nx.is_bipartite(G)
X, Y = nx.algorithms.bipartite.sets(G)
- #print(X)
+ # print(X)
assert set(range(n)) == X
assert set(range(n, n + m)) == Y
assert edges == len(list(G.edges()))
@@ -345,7 +345,7 @@ class TestGeneratorsBipartite():
assert len(G) == n + m
assert nx.is_bipartite(G)
X, Y = nx.algorithms.bipartite.sets(G)
- #print(X)
+ # print(X)
assert set(range(n)) == X
assert set(range(n, n + m)) == Y
assert edges == len(list(G.edges()))
diff --git a/networkx/algorithms/centrality/tests/test_betweenness_centrality.py b/networkx/algorithms/centrality/tests/test_betweenness_centrality.py
index 59396a57..5862d1ba 100644
--- a/networkx/algorithms/centrality/tests/test_betweenness_centrality.py
+++ b/networkx/algorithms/centrality/tests/test_betweenness_centrality.py
@@ -2,6 +2,7 @@
import networkx as nx
from networkx.testing import almost_equal
+
def weighted_G():
G = nx.Graph()
G.add_edge(0, 1, weight=3)
@@ -68,7 +69,7 @@ class TestBetweennessCentrality(object):
assert almost_equal(b[n], b_answer[n])
def test_sample_from_P3(self):
- G= nx.path_graph(3)
+ G = nx.path_graph(3)
b_answer = {0: 0.0, 1: 1.0, 2: 0.0}
b = nx.betweenness_centrality(G,
k=3,
diff --git a/networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py b/networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py
index c67130b1..3dc0f18c 100644
--- a/networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py
+++ b/networkx/algorithms/centrality/tests/test_betweenness_centrality_subset.py
@@ -2,6 +2,7 @@
import networkx as nx
from networkx.testing import almost_equal
+
class TestSubsetBetweennessCentrality:
def test_K5(self):
@@ -77,21 +78,21 @@ class TestSubsetBetweennessCentrality:
"""Betweenness Centrality Subset: Diamond Multi Path"""
G = nx.Graph()
G.add_edges_from([
- (1,2),
- (1,3),
- (1,4),
- (1,5),
- (1,10),
- (10,11),
- (11,12),
- (12,9),
- (2,6),
- (3,6),
- (4,6),
- (5,7),
- (7,8),
- (6,8),
- (8,9)
+ (1, 2),
+ (1, 3),
+ (1, 4),
+ (1, 5),
+ (1, 10),
+ (10, 11),
+ (11, 12),
+ (12, 9),
+ (2, 6),
+ (3, 6),
+ (4, 6),
+ (5, 7),
+ (7, 8),
+ (6, 8),
+ (8, 9)
])
b = nx.betweenness_centrality_subset(
G,
@@ -101,18 +102,18 @@ class TestSubsetBetweennessCentrality:
)
expected_b = {
- 1: 0,
- 2: 1./10,
- 3: 1./10,
- 4: 1./10,
- 5: 1./10,
- 6: 3./10,
- 7:1./10,
- 8:4./10,
- 9:0,
- 10:1./10,
- 11:1./10,
- 12:1./10,
+ 1: 0,
+ 2: 1./10,
+ 3: 1./10,
+ 4: 1./10,
+ 5: 1./10,
+ 6: 3./10,
+ 7: 1./10,
+ 8: 4./10,
+ 9: 0,
+ 10: 1./10,
+ 11: 1./10,
+ 12: 1./10,
}
for n in sorted(G):
diff --git a/networkx/algorithms/centrality/tests/test_closeness_centrality.py b/networkx/algorithms/centrality/tests/test_closeness_centrality.py
index 6ab4e15d..479520c8 100644
--- a/networkx/algorithms/centrality/tests/test_closeness_centrality.py
+++ b/networkx/algorithms/centrality/tests/test_closeness_centrality.py
@@ -5,6 +5,7 @@ import pytest
import networkx as nx
from networkx.testing import almost_equal
+
class TestClosenessCentrality:
@classmethod
def setup_class(cls):
@@ -17,7 +18,7 @@ class TestClosenessCentrality:
cls.T = nx.balanced_tree(r=2, h=2)
cls.Gb = nx.Graph()
cls.Gb.add_edges_from([(0, 1), (0, 2), (1, 3), (2, 3),
- (2, 4), (4, 5), (3, 5)])
+ (2, 4), (4, 5), (3, 5)])
F = nx.florentine_families_graph()
cls.F = F
@@ -200,7 +201,6 @@ class TestClosenessCentrality:
for n in sorted(XG):
assert almost_equal(c[n], d[n], places=3)
-
#
# Tests for incremental closeness centrality.
#
diff --git a/networkx/algorithms/centrality/tests/test_current_flow_closeness.py b/networkx/algorithms/centrality/tests/test_current_flow_closeness.py
index e3ab72e7..a18909cc 100644
--- a/networkx/algorithms/centrality/tests/test_current_flow_closeness.py
+++ b/networkx/algorithms/centrality/tests/test_current_flow_closeness.py
@@ -6,6 +6,7 @@ scipy = pytest.importorskip('scipy')
import networkx as nx
from networkx.testing import almost_equal
+
class TestFlowClosenessCentrality(object):
def test_K4(self):
diff --git a/networkx/algorithms/centrality/tests/test_degree_centrality.py b/networkx/algorithms/centrality/tests/test_degree_centrality.py
index c5aef07f..687d81d7 100644
--- a/networkx/algorithms/centrality/tests/test_degree_centrality.py
+++ b/networkx/algorithms/centrality/tests/test_degree_centrality.py
@@ -6,6 +6,7 @@
import networkx as nx
from networkx.testing import almost_equal
+
class TestDegreeCentrality:
def setup_method(self):
diff --git a/networkx/algorithms/centrality/tests/test_eigenvector_centrality.py b/networkx/algorithms/centrality/tests/test_eigenvector_centrality.py
index 33e68146..a2efac94 100644
--- a/networkx/algorithms/centrality/tests/test_eigenvector_centrality.py
+++ b/networkx/algorithms/centrality/tests/test_eigenvector_centrality.py
@@ -8,6 +8,7 @@ scipy = pytest.importorskip('scipy')
import networkx as nx
from networkx.testing import almost_equal
+
class TestEigenvectorCentrality(object):
def test_K5(self):
@@ -65,7 +66,7 @@ class TestEigenvectorCentralityDirected(object):
G.add_edges_from(edges, weight=2.0)
cls.G = G.reverse()
cls.G.evc = [0.25368793, 0.19576478, 0.32817092, 0.40430835,
- 0.48199885, 0.15724483, 0.51346196, 0.32475403]
+ 0.48199885, 0.15724483, 0.51346196, 0.32475403]
H = nx.DiGraph()
@@ -76,7 +77,7 @@ class TestEigenvectorCentralityDirected(object):
G.add_edges_from(edges)
cls.H = G.reverse()
cls.H.evc = [0.25368793, 0.19576478, 0.32817092, 0.40430835,
- 0.48199885, 0.15724483, 0.51346196, 0.32475403]
+ 0.48199885, 0.15724483, 0.51346196, 0.32475403]
def test_eigenvector_centrality_weighted(self):
G = self.G
diff --git a/networkx/algorithms/centrality/tests/test_harmonic_centrality.py b/networkx/algorithms/centrality/tests/test_harmonic_centrality.py
index 3adcfc5c..6b9ee9de 100644
--- a/networkx/algorithms/centrality/tests/test_harmonic_centrality.py
+++ b/networkx/algorithms/centrality/tests/test_harmonic_centrality.py
@@ -5,6 +5,7 @@ import networkx as nx
from networkx.algorithms.centrality import harmonic_centrality
from networkx.testing import almost_equal
+
class TestClosenessCentrality:
@classmethod
def setup_class(cls):
@@ -19,7 +20,7 @@ class TestClosenessCentrality:
cls.Gb = nx.DiGraph()
cls.Gb.add_edges_from([(0, 1), (0, 2), (0, 4), (2, 1),
- (2, 3), (4, 3)])
+ (2, 3), (4, 3)])
def test_p3_harmonic(self):
c = harmonic_centrality(self.P3)
diff --git a/networkx/algorithms/centrality/tests/test_katz_centrality.py b/networkx/algorithms/centrality/tests/test_katz_centrality.py
index 102a0515..0fdc2938 100644
--- a/networkx/algorithms/centrality/tests/test_katz_centrality.py
+++ b/networkx/algorithms/centrality/tests/test_katz_centrality.py
@@ -5,6 +5,7 @@ import networkx as nx
from networkx.testing import almost_equal
import pytest
+
class TestKatzCentrality(object):
def test_K5(self):
diff --git a/networkx/algorithms/centrality/tests/test_load_centrality.py b/networkx/algorithms/centrality/tests/test_load_centrality.py
index 5d296999..c7f76b9a 100644
--- a/networkx/algorithms/centrality/tests/test_load_centrality.py
+++ b/networkx/algorithms/centrality/tests/test_load_centrality.py
@@ -2,6 +2,7 @@
import networkx as nx
from networkx.testing import almost_equal
+
class TestLoadCentrality:
@classmethod
@@ -29,7 +30,7 @@ class TestLoadCentrality:
cls.T = nx.balanced_tree(r=2, h=2)
cls.Gb = nx.Graph()
cls.Gb.add_edges_from([(0, 1), (0, 2), (1, 3), (2, 3),
- (2, 4), (4, 5), (3, 5)])
+ (2, 4), (4, 5), (3, 5)])
cls.F = nx.florentine_families_graph()
cls.LM = nx.les_miserables_graph()
cls.D = nx.cycle_graph(3, create_using=nx.DiGraph())
diff --git a/networkx/algorithms/centrality/tests/test_percolation_centrality.py b/networkx/algorithms/centrality/tests/test_percolation_centrality.py
index ea59b66f..34e398e1 100644
--- a/networkx/algorithms/centrality/tests/test_percolation_centrality.py
+++ b/networkx/algorithms/centrality/tests/test_percolation_centrality.py
@@ -2,6 +2,7 @@
import networkx as nx
from networkx.testing import almost_equal
+
def example1a_G():
G = nx.Graph()
G.add_node(1, percolation=0.1)
diff --git a/networkx/algorithms/centrality/tests/test_reaching.py b/networkx/algorithms/centrality/tests/test_reaching.py
index 98ef5743..99005164 100644
--- a/networkx/algorithms/centrality/tests/test_reaching.py
+++ b/networkx/algorithms/centrality/tests/test_reaching.py
@@ -10,6 +10,7 @@ import pytest
from networkx import nx
from networkx.testing import almost_equal
+
class TestGlobalReachingCentrality:
"""Unit tests for the global reaching centrality function."""
diff --git a/networkx/algorithms/centrality/tests/test_subgraph.py b/networkx/algorithms/centrality/tests/test_subgraph.py
index 8ba68e08..8d76d95b 100644
--- a/networkx/algorithms/centrality/tests/test_subgraph.py
+++ b/networkx/algorithms/centrality/tests/test_subgraph.py
@@ -8,6 +8,7 @@ import networkx as nx
from networkx.algorithms.centrality.subgraph_alg import *
from networkx.testing import almost_equal
+
class TestSubgraph:
def test_subgraph_centrality(self):
diff --git a/networkx/algorithms/coloring/tests/test_coloring.py b/networkx/algorithms/coloring/tests/test_coloring.py
index 77574b9e..f7567916 100644
--- a/networkx/algorithms/coloring/tests/test_coloring.py
+++ b/networkx/algorithms/coloring/tests/test_coloring.py
@@ -62,7 +62,7 @@ class TestColoring:
if not hasattr(colors, '__len__'):
colors = [colors]
assert any(verify_length(coloring, n_colors)
- for n_colors in colors)
+ for n_colors in colors)
assert verify_coloring(graph, coloring)
for strategy, arglist in SPECIAL_TEST_CASES.items():
diff --git a/networkx/algorithms/community/label_propagation.py b/networkx/algorithms/community/label_propagation.py
index ec750fac..c40bc31f 100644
--- a/networkx/algorithms/community/label_propagation.py
+++ b/networkx/algorithms/community/label_propagation.py
@@ -91,7 +91,7 @@ def asyn_lpa_communities(G, weight=None, seed=None):
max_freq = max(label_freq.values())
best_labels = [label for label, freq in label_freq.items()
if freq == max_freq]
-
+
# Continue until all nodes have a majority label
if labels[node] not in best_labels:
labels[node] = seed.choice(best_labels)
diff --git a/networkx/algorithms/community/tests/test_label_propagation.py b/networkx/algorithms/community/tests/test_label_propagation.py
index 32586884..1f0b8bfe 100644
--- a/networkx/algorithms/community/tests/test_label_propagation.py
+++ b/networkx/algorithms/community/tests/test_label_propagation.py
@@ -98,7 +98,7 @@ def test_connected_communities():
def test_termination():
- # ensure termination of asyn_lpa_communities in two cases
+ # ensure termination of asyn_lpa_communities in two cases
# that led to an endless loop in a previous version
test1 = nx.karate_club_graph()
test2 = nx.caveman_graph(2, 10)
diff --git a/networkx/algorithms/community/tests/test_quality.py b/networkx/algorithms/community/tests/test_quality.py
index eda7bb35..f5c19122 100644
--- a/networkx/algorithms/community/tests/test_quality.py
+++ b/networkx/algorithms/community/tests/test_quality.py
@@ -19,6 +19,7 @@ from networkx.algorithms.community import performance
from networkx.algorithms.community.quality import inter_community_edges
from networkx.testing import almost_equal
+
class TestPerformance(object):
"""Unit tests for the :func:`performance` function."""
diff --git a/networkx/algorithms/components/tests/test_attracting.py b/networkx/algorithms/components/tests/test_attracting.py
index e6befd35..98cfd4ab 100644
--- a/networkx/algorithms/components/tests/test_attracting.py
+++ b/networkx/algorithms/components/tests/test_attracting.py
@@ -9,7 +9,7 @@ class TestAttractingComponents(object):
def setup_class(cls):
cls.G1 = nx.DiGraph()
cls.G1.add_edges_from([(5, 11), (11, 2), (11, 9), (11, 10),
- (7, 11), (7, 8), (8, 9), (3, 8), (3, 10)])
+ (7, 11), (7, 8), (8, 9), (3, 8), (3, 10)])
cls.G2 = nx.DiGraph()
cls.G2.add_edges_from([(0, 1), (0, 2), (1, 1), (1, 2), (2, 1)])
diff --git a/networkx/algorithms/components/tests/test_semiconnected.py b/networkx/algorithms/components/tests/test_semiconnected.py
index 35a7c090..3449d3aa 100644
--- a/networkx/algorithms/components/tests/test_semiconnected.py
+++ b/networkx/algorithms/components/tests/test_semiconnected.py
@@ -2,6 +2,7 @@ from itertools import chain
import networkx as nx
import pytest
+
class TestIsSemiconnected(object):
def test_undirected(self):
diff --git a/networkx/algorithms/connectivity/tests/test_connectivity.py b/networkx/algorithms/connectivity/tests/test_connectivity.py
index ed2a3ab9..cdfe3b7f 100644
--- a/networkx/algorithms/connectivity/tests/test_connectivity.py
+++ b/networkx/algorithms/connectivity/tests/test_connectivity.py
@@ -119,10 +119,10 @@ def test_complete_graphs():
G = nx.complete_graph(n)
assert n - 1 == nx.node_connectivity(G, flow_func=flow_func), msg.format(flow_func.__name__)
assert n - 1 == nx.node_connectivity(G.to_directed(),
- flow_func=flow_func), msg.format(flow_func.__name__)
+ flow_func=flow_func), msg.format(flow_func.__name__)
assert n - 1 == nx.edge_connectivity(G, flow_func=flow_func), msg.format(flow_func.__name__)
assert n - 1 == nx.edge_connectivity(G.to_directed(),
- flow_func=flow_func), msg.format(flow_func.__name__)
+ flow_func=flow_func), msg.format(flow_func.__name__)
def test_empty_graphs():
@@ -281,8 +281,8 @@ class TestAllPairsNodeConnectivity:
cls.K10 = nx.complete_graph(10)
cls.K5 = nx.complete_graph(5)
cls.G_list = [cls.path, cls.directed_path, cls.cycle,
- cls.directed_cycle, cls.gnp, cls.directed_gnp,
- cls.K10, cls.K5, cls.K20]
+ cls.directed_cycle, cls.gnp, cls.directed_gnp,
+ cls.K10, cls.K5, cls.K20]
def test_cycles(self):
K_undir = nx.all_pairs_node_connectivity(self.cycle)
@@ -334,7 +334,7 @@ class TestAllPairsNodeConnectivity:
A[u][v] = A[v][u] = nx.node_connectivity(G, u, v)
C = nx.all_pairs_node_connectivity(G)
assert (sorted((k, sorted(v)) for k, v in A.items()) ==
- sorted((k, sorted(v)) for k, v in C.items()))
+ sorted((k, sorted(v)) for k, v in C.items()))
def test_all_pairs_connectivity_directed(self):
G = nx.DiGraph()
@@ -345,7 +345,7 @@ class TestAllPairsNodeConnectivity:
A[u][v] = nx.node_connectivity(G, u, v)
C = nx.all_pairs_node_connectivity(G)
assert (sorted((k, sorted(v)) for k, v in A.items()) ==
- sorted((k, sorted(v)) for k, v in C.items()))
+ sorted((k, sorted(v)) for k, v in C.items()))
def test_all_pairs_connectivity_nbunch_combinations(self):
G = nx.complete_graph(5)
@@ -355,7 +355,7 @@ class TestAllPairsNodeConnectivity:
A[u][v] = A[v][u] = nx.node_connectivity(G, u, v)
C = nx.all_pairs_node_connectivity(G, nbunch=nbunch)
assert (sorted((k, sorted(v)) for k, v in A.items()) ==
- sorted((k, sorted(v)) for k, v in C.items()))
+ sorted((k, sorted(v)) for k, v in C.items()))
def test_all_pairs_connectivity_nbunch_iter(self):
G = nx.complete_graph(5)
@@ -365,4 +365,4 @@ class TestAllPairsNodeConnectivity:
A[u][v] = A[v][u] = nx.node_connectivity(G, u, v)
C = nx.all_pairs_node_connectivity(G, nbunch=iter(nbunch))
assert (sorted((k, sorted(v)) for k, v in A.items()) ==
- sorted((k, sorted(v)) for k, v in C.items()))
+ sorted((k, sorted(v)) for k, v in C.items()))
diff --git a/networkx/algorithms/connectivity/tests/test_edge_augmentation.py b/networkx/algorithms/connectivity/tests/test_edge_augmentation.py
index f87d837c..657c4ad1 100644
--- a/networkx/algorithms/connectivity/tests/test_edge_augmentation.py
+++ b/networkx/algorithms/connectivity/tests/test_edge_augmentation.py
@@ -449,11 +449,11 @@ def _check_augmentations(G, avail=None, max_k=None, weight=None,
if orig_k == 0:
# the approximation ratio is 3 if G is not connected
assert (info2['total_weight'] <=
- info1['total_weight'] * 3)
+ info1['total_weight'] * 3)
else:
# the approximation ratio is 2 if G is was connected
assert (info2['total_weight'] <=
- info1['total_weight'] * 2)
+ info1['total_weight'] * 2)
_check_unconstrained_bridge_property(G, info1)
diff --git a/networkx/algorithms/connectivity/tests/test_stoer_wagner.py b/networkx/algorithms/connectivity/tests/test_stoer_wagner.py
index 10fa53c8..3ae74499 100644
--- a/networkx/algorithms/connectivity/tests/test_stoer_wagner.py
+++ b/networkx/algorithms/connectivity/tests/test_stoer_wagner.py
@@ -2,6 +2,7 @@ from itertools import chain
import networkx as nx
import pytest
+
def _check_partition(G, cut_value, partition, weight):
assert isinstance(partition, tuple)
assert len(partition) == 2
diff --git a/networkx/algorithms/flow/tests/test_gomory_hu.py b/networkx/algorithms/flow/tests/test_gomory_hu.py
index aadd38da..b82a32f7 100644
--- a/networkx/algorithms/flow/tests/test_gomory_hu.py
+++ b/networkx/algorithms/flow/tests/test_gomory_hu.py
@@ -40,7 +40,7 @@ class TestGomoryHuTree:
for u, v in combinations(G, 2):
cut_value, edge = self.minimum_edge_weight(T, u, v)
assert (nx.minimum_cut_value(G, u, v) ==
- cut_value)
+ cut_value)
def test_karate_club_graph(self):
G = nx.karate_club_graph()
@@ -51,7 +51,7 @@ class TestGomoryHuTree:
for u, v in combinations(G, 2):
cut_value, edge = self.minimum_edge_weight(T, u, v)
assert (nx.minimum_cut_value(G, u, v) ==
- cut_value)
+ cut_value)
def test_davis_southern_women_graph(self):
G = nx.davis_southern_women_graph()
@@ -62,7 +62,7 @@ class TestGomoryHuTree:
for u, v in combinations(G, 2):
cut_value, edge = self.minimum_edge_weight(T, u, v)
assert (nx.minimum_cut_value(G, u, v) ==
- cut_value)
+ cut_value)
def test_florentine_families_graph(self):
G = nx.florentine_families_graph()
@@ -73,7 +73,7 @@ class TestGomoryHuTree:
for u, v in combinations(G, 2):
cut_value, edge = self.minimum_edge_weight(T, u, v)
assert (nx.minimum_cut_value(G, u, v) ==
- cut_value)
+ cut_value)
def test_les_miserables_graph_cutset(self):
G = nx.les_miserables_graph()
@@ -84,7 +84,7 @@ class TestGomoryHuTree:
for u, v in combinations(G, 2):
cut_value, edge = self.minimum_edge_weight(T, u, v)
assert (nx.minimum_cut_value(G, u, v) ==
- cut_value)
+ cut_value)
def test_karate_club_graph_cutset(self):
G = nx.karate_club_graph()
@@ -110,7 +110,7 @@ class TestGomoryHuTree:
for u, v in combinations(G, 2):
cut_value, edge = self.minimum_edge_weight(T, u, v)
assert (nx.minimum_cut_value(G, u, v, capacity='weight') ==
- cut_value)
+ cut_value)
def test_directed_raises(self):
with pytest.raises(nx.NetworkXNotImplemented):
diff --git a/networkx/algorithms/flow/tests/test_maxflow.py b/networkx/algorithms/flow/tests/test_maxflow.py
index b0d8695d..9961047d 100644
--- a/networkx/algorithms/flow/tests/test_maxflow.py
+++ b/networkx/algorithms/flow/tests/test_maxflow.py
@@ -395,7 +395,7 @@ class TestMaxFlowMinCutInterface:
if interface_func in max_min_funcs:
result = result[0]
assert fv == result, msgi.format(flow_func.__name__,
- interface_func.__name__)
+ interface_func.__name__)
def test_minimum_cut_no_cutoff(self):
G = self.G
@@ -418,7 +418,7 @@ class TestMaxFlowMinCutInterface:
if interface_func in max_min_funcs:
result = result[0]
assert fv == result, msgi.format(flow_func.__name__,
- interface_func.__name__)
+ interface_func.__name__)
def test_kwargs_default_flow_func(self):
G = self.H
@@ -439,7 +439,7 @@ class TestMaxFlowMinCutInterface:
if interface_func in max_min_funcs:
result = result[0]
assert fv == result, msgi.format(flow_func.__name__,
- interface_func.__name__)
+ interface_func.__name__)
# Tests specific to one algorithm
diff --git a/networkx/algorithms/flow/tests/test_maxflow_large_graph.py b/networkx/algorithms/flow/tests/test_maxflow_large_graph.py
index 2dd82f20..cfe056d5 100644
--- a/networkx/algorithms/flow/tests/test_maxflow_large_graph.py
+++ b/networkx/algorithms/flow/tests/test_maxflow_large_graph.py
@@ -74,7 +74,7 @@ def validate_flows(G, s, t, soln_value, R, flow_func):
if u == s:
assert exc == -soln_value, msg.format(flow_func.__name__)
elif u == t:
- assert exc ==soln_value, msg.format(flow_func.__name__)
+ assert exc == soln_value, msg.format(flow_func.__name__)
else:
assert exc == 0, msg.format(flow_func.__name__)
diff --git a/networkx/algorithms/flow/tests/test_mincost.py b/networkx/algorithms/flow/tests/test_mincost.py
index e4728100..9fe315be 100644
--- a/networkx/algorithms/flow/tests/test_mincost.py
+++ b/networkx/algorithms/flow/tests/test_mincost.py
@@ -330,7 +330,7 @@ class TestMinCostFlow:
G.nodes[4]['demand'] = -13
G.nodes[3]['demand'] = 13
- G.add_edges_from([(0,2), (0, 3), (2, 1)], capacity=20, weight=0.1)
+ G.add_edges_from([(0, 2), (0, 3), (2, 1)], capacity=20, weight=0.1)
pytest.raises(nx.NetworkXUnfeasible, nx.min_cost_flow, G)
def test_infinite_capacity_neg_digon(self):
diff --git a/networkx/algorithms/isomorphism/tests/test_ismags.py b/networkx/algorithms/isomorphism/tests/test_ismags.py
index 5999210b..85f1a97e 100644
--- a/networkx/algorithms/isomorphism/tests/test_ismags.py
+++ b/networkx/algorithms/isomorphism/tests/test_ismags.py
@@ -57,7 +57,7 @@ class TestSelfIsomorphism(object):
assert ismags.is_isomorphic()
assert ismags.subgraph_is_isomorphic()
assert (list(ismags.subgraph_isomorphisms_iter(symmetry=True)) ==
- [{n: n for n in graph.nodes}])
+ [{n: n for n in graph.nodes}])
def test_edgecase_self_isomorphism(self):
"""
@@ -93,7 +93,7 @@ class TestSelfIsomorphism(object):
assert ismags.is_isomorphic()
assert ismags.subgraph_is_isomorphic()
assert (list(ismags.subgraph_isomorphisms_iter(symmetry=True)) ==
- [{n: n for n in graph.nodes}])
+ [{n: n for n in graph.nodes}])
class TestSubgraphIsomorphism(object):
@@ -106,7 +106,7 @@ class TestSubgraphIsomorphism(object):
g2.add_edges_from([(n, m) for n, m in zip(g2, range(4, 8))])
ismags = iso.ISMAGS(g2, g1)
assert (list(ismags.subgraph_isomorphisms_iter(symmetry=True)) ==
- [{n: n for n in g1.nodes}])
+ [{n: n for n in g1.nodes}])
def test_isomorphism2(self):
g1 = nx.Graph()
@@ -121,14 +121,14 @@ class TestSubgraphIsomorphism(object):
{0: 0, 1: 1, 3: 2},
{2: 0, 1: 1, 3: 2}]
assert (_matches_to_sets(matches) ==
- _matches_to_sets(expected_symmetric))
+ _matches_to_sets(expected_symmetric))
matches = ismags.subgraph_isomorphisms_iter(symmetry=False)
expected_asymmetric = [{0: 2, 1: 1, 2: 0},
{0: 2, 1: 1, 3: 0},
{2: 2, 1: 1, 3: 0}]
assert (_matches_to_sets(matches) ==
- _matches_to_sets(expected_symmetric + expected_asymmetric))
+ _matches_to_sets(expected_symmetric + expected_asymmetric))
def test_labeled_nodes(self):
g1 = nx.Graph()
@@ -141,12 +141,12 @@ class TestSubgraphIsomorphism(object):
matches = ismags.subgraph_isomorphisms_iter(symmetry=True)
expected_symmetric = [{0: 0, 1: 1, 2: 2}]
assert (_matches_to_sets(matches) ==
- _matches_to_sets(expected_symmetric))
+ _matches_to_sets(expected_symmetric))
matches = ismags.subgraph_isomorphisms_iter(symmetry=False)
expected_asymmetric = [{0: 2, 1: 1, 2: 0}]
assert (_matches_to_sets(matches) ==
- _matches_to_sets(expected_symmetric + expected_asymmetric))
+ _matches_to_sets(expected_symmetric + expected_asymmetric))
def test_labeled_edges(self):
g1 = nx.Graph()
@@ -159,12 +159,12 @@ class TestSubgraphIsomorphism(object):
matches = ismags.subgraph_isomorphisms_iter(symmetry=True)
expected_symmetric = [{0: 0, 1: 1, 2: 2}]
assert (_matches_to_sets(matches) ==
- _matches_to_sets(expected_symmetric))
+ _matches_to_sets(expected_symmetric))
matches = ismags.subgraph_isomorphisms_iter(symmetry=False)
expected_asymmetric = [{1: 2, 0: 0, 2: 1}]
assert (_matches_to_sets(matches) ==
- _matches_to_sets(expected_symmetric + expected_asymmetric))
+ _matches_to_sets(expected_symmetric + expected_asymmetric))
class TestWikipediaExample(object):
diff --git a/networkx/algorithms/isomorphism/tests/test_isomorphvf2.py b/networkx/algorithms/isomorphism/tests/test_isomorphvf2.py
index 788cc913..dc564088 100644
--- a/networkx/algorithms/isomorphism/tests/test_isomorphvf2.py
+++ b/networkx/algorithms/isomorphism/tests/test_isomorphvf2.py
@@ -34,7 +34,7 @@ class TestWikipediaExample(object):
g2.add_edges_from(self.g2edges)
gm = iso.GraphMatcher(g1, g2)
assert gm.is_isomorphic()
- #Just testing some cases
+ # Just testing some cases
assert gm.subgraph_is_monomorphic()
mapping = sorted(gm.mapping.items())
@@ -53,7 +53,6 @@ class TestWikipediaExample(object):
gm = iso.GraphMatcher(g1, g3)
assert gm.subgraph_is_isomorphic()
-
def test_subgraph_mono(self):
g1 = nx.Graph()
g2 = nx.Graph()
@@ -112,7 +111,7 @@ class TestVF2GraphDB(object):
graph = self.create_graph(os.path.join(head, 'si2_b06_m200.B99'))
gm = iso.GraphMatcher(graph, subgraph)
assert gm.subgraph_is_isomorphic()
- #Just testing some cases
+ # Just testing some cases
assert gm.subgraph_is_monomorphic()
# There isn't a similar test implemented for subgraph monomorphism,
@@ -169,7 +168,7 @@ def test_multiedge():
else:
gm = iso.DiGraphMatcher(g1, g2)
assert gm.is_isomorphic()
- #Testing if monomorphism works in multigraphs
+ # Testing if monomorphism works in multigraphs
assert gm.subgraph_is_monomorphic()
@@ -191,12 +190,12 @@ def test_selfloop():
else:
gm = iso.DiGraphMatcher(g1, g2)
assert gm.is_isomorphic()
-
+
def test_selfloop_mono():
# Simple test for graphs with selfloops
edges0 = [(0, 1), (0, 2), (1, 2), (1, 3),
- (2, 4), (3, 1), (3, 2), (4, 2), (4, 5), (5, 4)]
+ (2, 4), (3, 1), (3, 2), (4, 2), (4, 5), (5, 4)]
edges = edges0 + [(2, 2)]
nodes = list(range(6))
@@ -252,7 +251,7 @@ def test_monomorphism_iter1():
assert {'A': 'Z', 'B': 'X', 'C': 'Y'} in x
assert len(x) == 3
gm21 = iso.DiGraphMatcher(g2, g1)
- #Check if StopIteration exception returns False
+ # Check if StopIteration exception returns False
assert not gm21.subgraph_is_monomorphic()
@@ -299,6 +298,7 @@ def test_multiple():
# assert_true(m['B'] == 'B')
# assert_true('C' not in m)
+
def test_noncomparable_nodes():
node1 = object()
node2 = object()
@@ -308,7 +308,7 @@ def test_noncomparable_nodes():
G = nx.path_graph([node1, node2, node3])
gm = iso.GraphMatcher(G, G)
assert gm.is_isomorphic()
- #Just testing some cases
+ # Just testing some cases
assert gm.subgraph_is_monomorphic()
# DiGraph
@@ -316,5 +316,5 @@ def test_noncomparable_nodes():
H = nx.path_graph([node3, node2, node1], create_using=nx.DiGraph)
dgm = iso.DiGraphMatcher(G, H)
assert dgm.is_isomorphic()
- #Just testing some cases
+ # Just testing some cases
assert gm.subgraph_is_monomorphic()
diff --git a/networkx/algorithms/isomorphism/tests/test_vf2userfunc.py b/networkx/algorithms/isomorphism/tests/test_vf2userfunc.py
index a86dcbbb..51004c0e 100644
--- a/networkx/algorithms/isomorphism/tests/test_vf2userfunc.py
+++ b/networkx/algorithms/isomorphism/tests/test_vf2userfunc.py
@@ -124,7 +124,7 @@ class TestNodeMatch_Graph(object):
# make the weights disagree
self.g1.add_edge('A', 'B', weight=2)
assert not nx.is_isomorphic(self.g1, self.g2,
- node_match=self.nm, edge_match=self.em)
+ node_match=self.nm, edge_match=self.em)
class TestEdgeMatch_MultiGraph(object):
diff --git a/networkx/algorithms/link_analysis/tests/test_hits.py b/networkx/algorithms/link_analysis/tests/test_hits.py
index 8634cadb..1d84253c 100644
--- a/networkx/algorithms/link_analysis/tests/test_hits.py
+++ b/networkx/algorithms/link_analysis/tests/test_hits.py
@@ -26,9 +26,9 @@ class TestHITS:
G.add_edges_from(edges, weight=1)
cls.G = G
cls.G.a = dict(zip(sorted(G), [0.000000, 0.000000, 0.366025,
- 0.133975, 0.500000, 0.000000]))
+ 0.133975, 0.500000, 0.000000]))
cls.G.h = dict(zip(sorted(G), [0.366025, 0.000000, 0.211325,
- 0.000000, 0.211325, 0.211325]))
+ 0.000000, 0.211325, 0.211325]))
def test_hits(self):
G = self.G
diff --git a/networkx/algorithms/link_analysis/tests/test_pagerank.py b/networkx/algorithms/link_analysis/tests/test_pagerank.py
index 57c5a839..87a37872 100644
--- a/networkx/algorithms/link_analysis/tests/test_pagerank.py
+++ b/networkx/algorithms/link_analysis/tests/test_pagerank.py
@@ -28,14 +28,14 @@ class TestPageRank(object):
G.add_edges_from(edges)
cls.G = G
cls.G.pagerank = dict(zip(sorted(G),
- [0.03721197, 0.05395735, 0.04150565,
- 0.37508082, 0.20599833, 0.28624589]))
+ [0.03721197, 0.05395735, 0.04150565,
+ 0.37508082, 0.20599833, 0.28624589]))
cls.dangling_node_index = 1
cls.dangling_edges = {1: 2, 2: 3,
- 3: 0, 4: 0, 5: 0, 6: 0}
+ 3: 0, 4: 0, 5: 0, 6: 0}
cls.G.dangling_pagerank = dict(zip(sorted(G),
- [0.10844518, 0.18618601, 0.0710892,
- 0.2683668, 0.15919783, 0.20671497]))
+ [0.10844518, 0.18618601, 0.0710892,
+ 0.2683668, 0.15919783, 0.20671497]))
def test_pagerank(self):
G = self.G
diff --git a/networkx/algorithms/operators/tests/test_all.py b/networkx/algorithms/operators/tests/test_all.py
index 094a99aa..7d44ef22 100644
--- a/networkx/algorithms/operators/tests/test_all.py
+++ b/networkx/algorithms/operators/tests/test_all.py
@@ -104,12 +104,12 @@ def test_union_all_and_compose_all():
pytest.raises(nx.NetworkXError, nx.union, K3, P3)
H1 = nx.union_all([H, G1], rename=('H', 'G1'))
assert (sorted(H1.nodes()) ==
- ['G1A', 'G1B', 'G1C', 'G1D',
- 'H1', 'H2', 'H3', 'H4', 'HA', 'HB', 'HC', 'HD'])
+ ['G1A', 'G1B', 'G1C', 'G1D',
+ 'H1', 'H2', 'H3', 'H4', 'HA', 'HB', 'HC', 'HD'])
H2 = nx.union_all([H, G2], rename=("H", ""))
assert (sorted(H2.nodes()) ==
- ['1', '2', '3', '4',
+ ['1', '2', '3', '4',
'H1', 'H2', 'H3', 'H4', 'HA', 'HB', 'HC', 'HD'])
assert not H1.has_edge('NB', 'NA')
@@ -119,7 +119,7 @@ def test_union_all_and_compose_all():
G2 = nx.union_all([G2, G2], rename=('', 'copy'))
assert (sorted(G2.nodes()) ==
- ['1', '2', '3', '4', 'copy1', 'copy2', 'copy3', 'copy4'])
+ ['1', '2', '3', '4', 'copy1', 'copy2', 'copy3', 'copy4'])
assert sorted(G2.neighbors('copy4')) == []
assert sorted(G2.neighbors('copy1')) == ['copy2', 'copy3', 'copy4']
@@ -141,8 +141,8 @@ def test_union_all_and_compose_all():
G3.add_edge(11, 22)
G4 = nx.union_all([G1, G2, G3], rename=("G1", "G2", "G3"))
assert (sorted(G4.nodes()) ==
- ['G1A', 'G1B', 'G21', 'G22',
- 'G311', 'G322'])
+ ['G1A', 'G1B', 'G21', 'G22',
+ 'G311', 'G322'])
def test_union_all_multigraph():
@@ -155,7 +155,7 @@ def test_union_all_multigraph():
GH = nx.union_all([G, H])
assert set(GH) == set(G) | set(H)
assert (set(GH.edges(keys=True)) ==
- set(G.edges(keys=True)) | set(H.edges(keys=True)))
+ set(G.edges(keys=True)) | set(H.edges(keys=True)))
def test_input_output():
diff --git a/networkx/algorithms/operators/tests/test_binary.py b/networkx/algorithms/operators/tests/test_binary.py
index b27f26c0..030fe62d 100644
--- a/networkx/algorithms/operators/tests/test_binary.py
+++ b/networkx/algorithms/operators/tests/test_binary.py
@@ -171,7 +171,7 @@ def test_symmetric_difference_multigraph():
assert set(gh.nodes()) == set(h.nodes())
assert sorted(gh.edges()) == 3 * [(0, 1)]
assert (sorted(sorted(e) for e in gh.edges(keys=True)) ==
- [[0, 1, 1], [0, 1, 2], [0, 1, 3]])
+ [[0, 1, 1], [0, 1, 2], [0, 1, 3]])
def test_union_and_compose():
@@ -194,12 +194,12 @@ def test_union_and_compose():
pytest.raises(nx.NetworkXError, nx.union, K3, P3)
H1 = nx.union(H, G1, rename=('H', 'G1'))
assert (sorted(H1.nodes()) ==
- ['G1A', 'G1B', 'G1C', 'G1D',
- 'H1', 'H2', 'H3', 'H4', 'HA', 'HB', 'HC', 'HD'])
+ ['G1A', 'G1B', 'G1C', 'G1D',
+ 'H1', 'H2', 'H3', 'H4', 'HA', 'HB', 'HC', 'HD'])
H2 = nx.union(H, G2, rename=("H", ""))
assert (sorted(H2.nodes()) ==
- ['1', '2', '3', '4',
+ ['1', '2', '3', '4',
'H1', 'H2', 'H3', 'H4', 'HA', 'HB', 'HC', 'HD'])
assert not H1.has_edge('NB', 'NA')
@@ -209,7 +209,7 @@ def test_union_and_compose():
G2 = nx.union(G2, G2, rename=('', 'copy'))
assert (sorted(G2.nodes()) ==
- ['1', '2', '3', '4', 'copy1', 'copy2', 'copy3', 'copy4'])
+ ['1', '2', '3', '4', 'copy1', 'copy2', 'copy3', 'copy4'])
assert sorted(G2.neighbors('copy4')) == []
assert sorted(G2.neighbors('copy1')) == ['copy2', 'copy3', 'copy4']
@@ -241,7 +241,7 @@ def test_union_multigraph():
GH = nx.union(G, H)
assert set(GH) == set(G) | set(H)
assert (set(GH.edges(keys=True)) ==
- set(G.edges(keys=True)) | set(H.edges(keys=True)))
+ set(G.edges(keys=True)) | set(H.edges(keys=True)))
def test_disjoint_union_multigraph():
@@ -254,7 +254,7 @@ def test_disjoint_union_multigraph():
GH = nx.disjoint_union(G, H)
assert set(GH) == set(G) | set(H)
assert (set(GH.edges(keys=True)) ==
- set(G.edges(keys=True)) | set(H.edges(keys=True)))
+ set(G.edges(keys=True)) | set(H.edges(keys=True)))
def test_compose_multigraph():
@@ -267,12 +267,12 @@ def test_compose_multigraph():
GH = nx.compose(G, H)
assert set(GH) == set(G) | set(H)
assert (set(GH.edges(keys=True)) ==
- set(G.edges(keys=True)) | set(H.edges(keys=True)))
+ set(G.edges(keys=True)) | set(H.edges(keys=True)))
H.add_edge(1, 2, key=2)
GH = nx.compose(G, H)
assert set(GH) == set(G) | set(H)
assert (set(GH.edges(keys=True)) ==
- set(G.edges(keys=True)) | set(H.edges(keys=True)))
+ set(G.edges(keys=True)) | set(H.edges(keys=True)))
def test_full_join_graph():
@@ -287,14 +287,14 @@ def test_full_join_graph():
assert set(U) == set(G) | set(H)
assert len(U) == len(G) + len(H)
assert (len(U.edges()) ==
- len(G.edges()) + len(H.edges()) + len(G) * len(H))
+ len(G.edges()) + len(H.edges()) + len(G) * len(H))
# Rename
U = nx.full_join(G, H, rename=('g', 'h'))
assert set(U) == set(['g0', 'g1', 'g2', 'h3', 'h4'])
assert len(U) == len(G) + len(H)
assert (len(U.edges()) ==
- len(G.edges()) + len(H.edges()) + len(G) * len(H))
+ len(G.edges()) + len(H.edges()) + len(G) * len(H))
# Rename graphs with string-like nodes
G = nx.Graph()
@@ -307,7 +307,7 @@ def test_full_join_graph():
assert set(U) == set(['ga', 'gb', 'gc', 'hd', 'he'])
assert len(U) == len(G) + len(H)
assert (len(U.edges()) ==
- len(G.edges()) + len(H.edges()) + len(G) * len(H))
+ len(G.edges()) + len(H.edges()) + len(G) * len(H))
# DiGraphs
G = nx.DiGraph()
@@ -320,14 +320,14 @@ def test_full_join_graph():
assert set(U) == set(G) | set(H)
assert len(U) == len(G) + len(H)
assert (len(U.edges()) ==
- len(G.edges()) + len(H.edges()) + len(G)*len(H) * 2)
+ len(G.edges()) + len(H.edges()) + len(G)*len(H) * 2)
# DiGraphs Rename
U = nx.full_join(G, H, rename=('g', 'h'))
assert set(U) == set(['g0', 'g1', 'g2', 'h3', 'h4'])
assert len(U) == len(G) + len(H)
assert (len(U.edges()) ==
- len(G.edges()) + len(H.edges()) + len(G) * len(H) * 2)
+ len(G.edges()) + len(H.edges()) + len(G) * len(H) * 2)
def test_full_join_multigraph():
@@ -342,14 +342,14 @@ def test_full_join_multigraph():
assert set(U) == set(G) | set(H)
assert len(U) == len(G) + len(H)
assert (len(U.edges()) ==
- len(G.edges()) + len(H.edges()) + len(G) * len(H))
+ len(G.edges()) + len(H.edges()) + len(G) * len(H))
# MultiGraphs rename
U = nx.full_join(G, H, rename=('g', 'h'))
assert set(U) == set(['g0', 'g1', 'g2', 'h3', 'h4'])
assert len(U) == len(G) + len(H)
assert (len(U.edges()) ==
- len(G.edges()) + len(H.edges()) + len(G) * len(H))
+ len(G.edges()) + len(H.edges()) + len(G) * len(H))
# MultiDiGraphs
G = nx.MultiDiGraph()
@@ -362,14 +362,14 @@ def test_full_join_multigraph():
assert set(U) == set(G) | set(H)
assert len(U) == len(G) + len(H)
assert (len(U.edges()) ==
- len(G.edges()) + len(H.edges()) + len(G) * len(H) * 2)
+ len(G.edges()) + len(H.edges()) + len(G) * len(H) * 2)
# MultiDiGraphs rename
U = nx.full_join(G, H, rename=('g', 'h'))
assert set(U) == set(['g0', 'g1', 'g2', 'h3', 'h4'])
assert len(U) == len(G) + len(H)
assert (len(U.edges()) ==
- len(G.edges()) + len(H.edges()) + len(G) * len(H) * 2)
+ len(G.edges()) + len(H.edges()) + len(G) * len(H) * 2)
def test_mixed_type_union():
diff --git a/networkx/algorithms/operators/tests/test_product.py b/networkx/algorithms/operators/tests/test_product.py
index b6649aa8..bdb4c6cc 100644
--- a/networkx/algorithms/operators/tests/test_product.py
+++ b/networkx/algorithms/operators/tests/test_product.py
@@ -107,11 +107,11 @@ def test_cartesian_product_multigraph():
GH = nx.cartesian_product(G, H)
assert set(GH) == {(1, 3), (2, 3), (2, 4), (1, 4)}
assert ({(frozenset([u, v]), k) for u, v, k in GH.edges(keys=True)} ==
- {(frozenset([u, v]), k) for u, v, k in
- [((1, 3), (2, 3), 0), ((1, 3), (2, 3), 1),
- ((1, 3), (1, 4), 0), ((1, 3), (1, 4), 1),
- ((2, 3), (2, 4), 0), ((2, 3), (2, 4), 1),
- ((2, 4), (1, 4), 0), ((2, 4), (1, 4), 1)]})
+ {(frozenset([u, v]), k) for u, v, k in
+ [((1, 3), (2, 3), 0), ((1, 3), (2, 3), 1),
+ ((1, 3), (1, 4), 0), ((1, 3), (1, 4), 1),
+ ((2, 3), (2, 4), 0), ((2, 3), (2, 4), 1),
+ ((2, 4), (1, 4), 0), ((2, 4), (1, 4), 1)]})
def test_cartesian_product_raises():
@@ -160,13 +160,13 @@ def test_cartesian_product_size():
G = nx.cartesian_product(P5, K3)
assert nx.number_of_nodes(G) == 5 * 3
assert (nx.number_of_edges(G) ==
- nx.number_of_edges(P5) * nx.number_of_nodes(K3) +
- nx.number_of_edges(K3) * nx.number_of_nodes(P5))
+ nx.number_of_edges(P5) * nx.number_of_nodes(K3) +
+ nx.number_of_edges(K3) * nx.number_of_nodes(P5))
G = nx.cartesian_product(K3, K5)
assert nx.number_of_nodes(G) == 3 * 5
assert (nx.number_of_edges(G) ==
- nx.number_of_edges(K5) * nx.number_of_nodes(K3) +
- nx.number_of_edges(K3) * nx.number_of_nodes(K5))
+ nx.number_of_edges(K5) * nx.number_of_nodes(K3) +
+ nx.number_of_edges(K3) * nx.number_of_nodes(K5))
def test_cartesian_product_classic():
diff --git a/networkx/algorithms/operators/tests/test_unary.py b/networkx/algorithms/operators/tests/test_unary.py
index f954a081..75c74f71 100644
--- a/networkx/algorithms/operators/tests/test_unary.py
+++ b/networkx/algorithms/operators/tests/test_unary.py
@@ -36,9 +36,9 @@ def test_complement_2():
G1.add_edge('A', 'D')
G1C = nx.complement(G1)
assert (sorted(G1C.edges()) ==
- [('B', 'A'), ('B', 'C'),
- ('B', 'D'), ('C', 'A'), ('C', 'B'),
- ('C', 'D'), ('D', 'A'), ('D', 'B'), ('D', 'C')])
+ [('B', 'A'), ('B', 'C'),
+ ('B', 'D'), ('C', 'A'), ('C', 'B'),
+ ('C', 'D'), ('D', 'A'), ('D', 'B'), ('D', 'C')])
def test_reverse1():
diff --git a/networkx/algorithms/shortest_paths/tests/test_dense.py b/networkx/algorithms/shortest_paths/tests/test_dense.py
index b2446d01..6c9ab466 100644
--- a/networkx/algorithms/shortest_paths/tests/test_dense.py
+++ b/networkx/algorithms/shortest_paths/tests/test_dense.py
@@ -19,11 +19,11 @@ class TestFloyd:
assert dist['s']['v'] == 9
assert path['s']['v'] == 'u'
assert (dist ==
- {'y': {'y': 0, 'x': 12, 's': 7, 'u': 15, 'v': 6},
- 'x': {'y': 2, 'x': 0, 's': 9, 'u': 3, 'v': 4},
- 's': {'y': 7, 'x': 5, 's': 0, 'u': 8, 'v': 9},
- 'u': {'y': 2, 'x': 2, 's': 9, 'u': 0, 'v': 1},
- 'v': {'y': 1, 'x': 13, 's': 8, 'u': 16, 'v': 0}})
+ {'y': {'y': 0, 'x': 12, 's': 7, 'u': 15, 'v': 6},
+ 'x': {'y': 2, 'x': 0, 's': 9, 'u': 3, 'v': 4},
+ 's': {'y': 7, 'x': 5, 's': 0, 'u': 8, 'v': 9},
+ 'u': {'y': 2, 'x': 2, 's': 9, 'u': 0, 'v': 1},
+ 'v': {'y': 1, 'x': 13, 's': 8, 'u': 16, 'v': 0}})
GG = XG.to_undirected()
# make sure we get lower weight
@@ -58,14 +58,14 @@ class TestFloyd:
path, dist = nx.floyd_warshall_predecessor_and_distance(XG)
inf = float("inf")
assert (dist ==
- {'v': {'v': 0, 'x': 5.0, 'y': 6.0, 'u': 7.0},
- 'x': {'x': 0, 'u': 2.0, 'v': inf, 'y': inf},
- 'y': {'y': 0, 'x': 5.0, 'v': inf, 'u': 7.0},
- 'u': {'u': 0, 'v': inf, 'x': inf, 'y': inf}})
+ {'v': {'v': 0, 'x': 5.0, 'y': 6.0, 'u': 7.0},
+ 'x': {'x': 0, 'u': 2.0, 'v': inf, 'y': inf},
+ 'y': {'y': 0, 'x': 5.0, 'v': inf, 'u': 7.0},
+ 'u': {'u': 0, 'v': inf, 'x': inf, 'y': inf}})
assert (path ==
- {'v': {'x': 'v', 'y': 'v', 'u': 'x'},
- 'x': {'u': 'x'},
- 'y': {'x': 'y', 'u': 'x'}})
+ {'v': {'x': 'v', 'y': 'v', 'u': 'x'},
+ 'x': {'u': 'x'},
+ 'y': {'x': 'y', 'u': 'x'}})
def test_reconstruct_path(self):
with pytest.raises(KeyError):
diff --git a/networkx/algorithms/shortest_paths/tests/test_generic.py b/networkx/algorithms/shortest_paths/tests/test_generic.py
index d4953263..7f558fc7 100644
--- a/networkx/algorithms/shortest_paths/tests/test_generic.py
+++ b/networkx/algorithms/shortest_paths/tests/test_generic.py
@@ -4,6 +4,7 @@ import pytest
import networkx as nx
from networkx.testing import almost_equal
+
def validate_grid_path(r, c, s, t, p):
assert isinstance(p, list)
assert p[0] == s
@@ -25,7 +26,7 @@ class TestGenericPath:
def setup_class(cls):
from networkx import convert_node_labels_to_integers as cnlti
cls.grid = cnlti(nx.grid_2d_graph(4, 4), first_label=1,
- ordering="sorted")
+ ordering="sorted")
cls.cycle = nx.cycle_graph(7)
cls.directed_cycle = nx.cycle_graph(7, create_using=nx.DiGraph())
cls.neg_weights = nx.DiGraph()
@@ -41,26 +42,26 @@ class TestGenericPath:
assert nx.shortest_path(self.directed_cycle, 0, 3) == [0, 1, 2, 3]
# now with weights
assert (nx.shortest_path(self.cycle, 0, 3, weight='weight') ==
- [0, 1, 2, 3])
+ [0, 1, 2, 3])
assert (nx.shortest_path(self.cycle, 0, 4, weight='weight') ==
- [0, 6, 5, 4])
+ [0, 6, 5, 4])
validate_grid_path(4, 4, 1, 12, nx.shortest_path(self.grid, 1, 12,
weight='weight'))
assert (nx.shortest_path(self.directed_cycle, 0, 3,
- weight='weight') ==
- [0, 1, 2, 3])
+ weight='weight') ==
+ [0, 1, 2, 3])
# weights and method specified
assert (nx.shortest_path(self.directed_cycle, 0, 3,
- weight='weight', method='dijkstra') ==
- [0, 1, 2, 3])
+ weight='weight', method='dijkstra') ==
+ [0, 1, 2, 3])
assert (nx.shortest_path(self.directed_cycle, 0, 3,
- weight='weight', method='bellman-ford') ==
- [0, 1, 2, 3])
+ weight='weight', method='bellman-ford') ==
+ [0, 1, 2, 3])
# when Dijkstra's will probably (depending on precise implementation)
# incorrectly return [0, 1, 3] instead
assert (nx.shortest_path(self.neg_weights, 0, 3, weight='weight',
- method='bellman-ford') ==
- [0, 2, 3])
+ method='bellman-ford') ==
+ [0, 2, 3])
# confirm bad method rejection
pytest.raises(ValueError, nx.shortest_path, self.cycle, method='SPAM')
# confirm absent source rejection
@@ -87,21 +88,21 @@ class TestGenericPath:
assert nx.shortest_path_length(self.directed_cycle, 0, 4) == 4
# now with weights
assert (nx.shortest_path_length(self.cycle, 0, 3,
- weight='weight') ==
- 3)
+ weight='weight') ==
+ 3)
assert (nx.shortest_path_length(self.grid, 1, 12,
- weight='weight') ==
- 5)
+ weight='weight') ==
+ 5)
assert (nx.shortest_path_length(self.directed_cycle, 0, 4,
- weight='weight') ==
- 4)
+ weight='weight') ==
+ 4)
# weights and method specified
assert (nx.shortest_path_length(self.cycle, 0, 3, weight='weight',
- method='dijkstra') ==
- 3)
+ method='dijkstra') ==
+ 3)
assert (nx.shortest_path_length(self.cycle, 0, 3, weight='weight',
- method='bellman-ford') ==
- 3)
+ method='bellman-ford') ==
+ 3)
# confirm bad method rejection
pytest.raises(ValueError,
nx.shortest_path_length,
@@ -151,8 +152,8 @@ class TestGenericPath:
ans = dict(nx.shortest_path_length(self.cycle, 0))
assert ans == {0: 0, 1: 1, 2: 2, 3: 3, 4: 3, 5: 2, 6: 1}
assert (ans ==
- dict(nx.single_source_shortest_path_length(self.cycle,
- 0)))
+ dict(nx.single_source_shortest_path_length(self.cycle,
+ 0)))
ans = dict(nx.shortest_path_length(self.grid, 1))
assert ans[16] == 6
# now with weights
@@ -216,7 +217,7 @@ class TestGenericPath:
method='bellman-ford'))
assert ans[0] == {0: 0, 1: 1, 2: 2, 3: 3, 4: 3, 5: 2, 6: 1}
assert (ans ==
- dict(nx.all_pairs_bellman_ford_path_length(self.cycle)))
+ dict(nx.all_pairs_bellman_ford_path_length(self.cycle)))
def test_has_path(self):
G = nx.Graph()
@@ -230,26 +231,26 @@ class TestGenericPath:
nx.add_path(G, [0, 1, 2, 3])
nx.add_path(G, [0, 10, 20, 3])
assert ([[0, 1, 2, 3], [0, 10, 20, 3]] ==
- sorted(nx.all_shortest_paths(G, 0, 3)))
+ sorted(nx.all_shortest_paths(G, 0, 3)))
# with weights
G = nx.Graph()
nx.add_path(G, [0, 1, 2, 3])
nx.add_path(G, [0, 10, 20, 3])
assert ([[0, 1, 2, 3], [0, 10, 20, 3]] ==
- sorted(nx.all_shortest_paths(G, 0, 3, weight='weight')))
+ sorted(nx.all_shortest_paths(G, 0, 3, weight='weight')))
# weights and method specified
G = nx.Graph()
nx.add_path(G, [0, 1, 2, 3])
nx.add_path(G, [0, 10, 20, 3])
assert ([[0, 1, 2, 3], [0, 10, 20, 3]] ==
- sorted(nx.all_shortest_paths(G, 0, 3, weight='weight',
- method='dijkstra')))
+ sorted(nx.all_shortest_paths(G, 0, 3, weight='weight',
+ method='dijkstra')))
G = nx.Graph()
nx.add_path(G, [0, 1, 2, 3])
nx.add_path(G, [0, 10, 20, 3])
assert ([[0, 1, 2, 3], [0, 10, 20, 3]] ==
- sorted(nx.all_shortest_paths(G, 0, 3, weight='weight',
- method='bellman-ford')))
+ sorted(nx.all_shortest_paths(G, 0, 3, weight='weight',
+ method='bellman-ford')))
def test_all_shortest_paths_raise(self):
with pytest.raises(nx.NetworkXNoPath):
@@ -353,7 +354,6 @@ class TestAverageShortestPathLengthNumpy(object):
numpy = pytest.importorskip('numpy')
npt = pytest.importorskip('numpy.testing')
-
def test_specified_methods_numpy(self):
G = nx.Graph()
nx.add_cycle(G, range(7), weight=2)
diff --git a/networkx/algorithms/shortest_paths/tests/test_unweighted.py b/networkx/algorithms/shortest_paths/tests/test_unweighted.py
index 9cf63fbd..b2c41e5d 100644
--- a/networkx/algorithms/shortest_paths/tests/test_unweighted.py
+++ b/networkx/algorithms/shortest_paths/tests/test_unweighted.py
@@ -28,12 +28,12 @@ class TestUnweightedPath:
def test_bidirectional_shortest_path(self):
assert (nx.bidirectional_shortest_path(self.cycle, 0, 3) ==
- [0, 1, 2, 3])
+ [0, 1, 2, 3])
assert (nx.bidirectional_shortest_path(self.cycle, 0, 4) ==
- [0, 6, 5, 4])
+ [0, 6, 5, 4])
validate_grid_path(4, 4, 1, 12, nx.bidirectional_shortest_path(self.grid, 1, 12))
assert (nx.bidirectional_shortest_path(self.directed_cycle, 0, 3) ==
- [0, 1, 2, 3])
+ [0, 1, 2, 3])
def test_shortest_path_length(self):
assert nx.shortest_path_length(self.cycle, 0, 3) == 3
diff --git a/networkx/algorithms/shortest_paths/tests/test_weighted.py b/networkx/algorithms/shortest_paths/tests/test_weighted.py
index 6d97787a..4de07d21 100644
--- a/networkx/algorithms/shortest_paths/tests/test_weighted.py
+++ b/networkx/algorithms/shortest_paths/tests/test_weighted.py
@@ -166,7 +166,7 @@ class TestWeightedPath(WeightedTestBase):
def test_dijkstra_predecessor1(self):
G = nx.path_graph(4)
assert (nx.dijkstra_predecessor_and_distance(G, 0) ==
- ({0: [], 1: [0], 2: [1], 3: [2]}, {0: 0, 1: 1, 2: 2, 3: 3}))
+ ({0: [], 1: [0], 2: [1], 3: [2]}, {0: 0, 1: 1, 2: 2, 3: 3}))
def test_dijkstra_predecessor2(self):
# 4-cycle
@@ -412,36 +412,36 @@ class TestBellmanFordAndGoldbergRadzik(WeightedTestBase):
G = nx.cycle_graph(5, create_using=nx.DiGraph())
G.add_edge(1, 2, weight=-3)
assert (nx.single_source_bellman_ford_path(G, 0) ==
- {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3], 4: [0, 1, 2, 3, 4]})
+ {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3], 4: [0, 1, 2, 3, 4]})
assert (nx.single_source_bellman_ford_path_length(G, 0) ==
- {0: 0, 1: 1, 2: -2, 3: -1, 4: 0})
+ {0: 0, 1: 1, 2: -2, 3: -1, 4: 0})
assert (nx.single_source_bellman_ford(G, 0) ==
- ({0: 0, 1: 1, 2: -2, 3: -1, 4: 0},
- {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3], 4: [0, 1, 2, 3, 4]}))
+ ({0: 0, 1: 1, 2: -2, 3: -1, 4: 0},
+ {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3], 4: [0, 1, 2, 3, 4]}))
assert (nx.bellman_ford_predecessor_and_distance(G, 0) ==
- ({0: [], 1: [0], 2: [1], 3: [2], 4: [3]},
- {0: 0, 1: 1, 2: -2, 3: -1, 4: 0}))
+ ({0: [], 1: [0], 2: [1], 3: [2], 4: [3]},
+ {0: 0, 1: 1, 2: -2, 3: -1, 4: 0}))
assert (nx.goldberg_radzik(G, 0) ==
- ({0: None, 1: 0, 2: 1, 3: 2, 4: 3},
- {0: 0, 1: 1, 2: -2, 3: -1, 4: 0}))
+ ({0: None, 1: 0, 2: 1, 3: 2, 4: 3},
+ {0: 0, 1: 1, 2: -2, 3: -1, 4: 0}))
def test_not_connected(self):
G = nx.complete_graph(6)
G.add_edge(10, 11)
G.add_edge(10, 12)
assert (nx.single_source_bellman_ford_path(G, 0) ==
- {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]})
+ {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]})
assert (nx.single_source_bellman_ford_path_length(G, 0) ==
- {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1})
+ {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1})
assert (nx.single_source_bellman_ford(G, 0) ==
- ({0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1},
- {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]}))
+ ({0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1},
+ {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]}))
assert (nx.bellman_ford_predecessor_and_distance(G, 0) ==
- ({0: [], 1: [0], 2: [0], 3: [0], 4: [0], 5: [0]},
- {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}))
+ ({0: [], 1: [0], 2: [0], 3: [0], 4: [0], 5: [0]},
+ {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}))
assert (nx.goldberg_radzik(G, 0) ==
- ({0: None, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0},
- {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}))
+ ({0: None, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0},
+ {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}))
# not connected, with a component not containing the source that
# contains a negative cost cycle.
@@ -450,18 +450,18 @@ class TestBellmanFordAndGoldbergRadzik(WeightedTestBase):
('B', 'C', {'load': -10}),
('C', 'A', {'load': 2})])
assert (nx.single_source_bellman_ford_path(G, 0, weight='load') ==
- {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]})
+ {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]})
assert (nx.single_source_bellman_ford_path_length(G, 0, weight='load') ==
- {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1})
+ {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1})
assert (nx.single_source_bellman_ford(G, 0, weight='load') ==
- ({0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1},
- {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]}))
+ ({0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1},
+ {0: [0], 1: [0, 1], 2: [0, 2], 3: [0, 3], 4: [0, 4], 5: [0, 5]}))
assert (nx.bellman_ford_predecessor_and_distance(G, 0, weight='load') ==
- ({0: [], 1: [0], 2: [0], 3: [0], 4: [0], 5: [0]},
- {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}))
+ ({0: [], 1: [0], 2: [0], 3: [0], 4: [0], 5: [0]},
+ {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}))
assert (nx.goldberg_radzik(G, 0, weight='load') ==
- ({0: None, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0},
- {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}))
+ ({0: None, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0},
+ {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}))
def test_multigraph(self):
assert nx.bellman_ford_path(self.MXG, 's', 'v') == ['s', 'x', 'u', 'v']
@@ -509,25 +509,25 @@ class TestBellmanFordAndGoldbergRadzik(WeightedTestBase):
def test_path_graph(self):
G = nx.path_graph(4)
assert (nx.single_source_bellman_ford_path(G, 0) ==
- {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3]})
+ {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3]})
assert (nx.single_source_bellman_ford_path_length(G, 0) ==
- {0: 0, 1: 1, 2: 2, 3: 3})
+ {0: 0, 1: 1, 2: 2, 3: 3})
assert (nx.single_source_bellman_ford(G, 0) ==
- ({0: 0, 1: 1, 2: 2, 3: 3}, {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3]}))
+ ({0: 0, 1: 1, 2: 2, 3: 3}, {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2, 3]}))
assert (nx.bellman_ford_predecessor_and_distance(G, 0) ==
- ({0: [], 1: [0], 2: [1], 3: [2]}, {0: 0, 1: 1, 2: 2, 3: 3}))
+ ({0: [], 1: [0], 2: [1], 3: [2]}, {0: 0, 1: 1, 2: 2, 3: 3}))
assert (nx.goldberg_radzik(G, 0) ==
- ({0: None, 1: 0, 2: 1, 3: 2}, {0: 0, 1: 1, 2: 2, 3: 3}))
+ ({0: None, 1: 0, 2: 1, 3: 2}, {0: 0, 1: 1, 2: 2, 3: 3}))
assert (nx.single_source_bellman_ford_path(G, 3) ==
- {0: [3, 2, 1, 0], 1: [3, 2, 1], 2: [3, 2], 3: [3]})
+ {0: [3, 2, 1, 0], 1: [3, 2, 1], 2: [3, 2], 3: [3]})
assert (nx.single_source_bellman_ford_path_length(G, 3) ==
- {0: 3, 1: 2, 2: 1, 3: 0})
+ {0: 3, 1: 2, 2: 1, 3: 0})
assert (nx.single_source_bellman_ford(G, 3) ==
- ({0: 3, 1: 2, 2: 1, 3: 0}, {0: [3, 2, 1, 0], 1: [3, 2, 1], 2: [3, 2], 3: [3]}))
+ ({0: 3, 1: 2, 2: 1, 3: 0}, {0: [3, 2, 1, 0], 1: [3, 2, 1], 2: [3, 2], 3: [3]}))
assert (nx.bellman_ford_predecessor_and_distance(G, 3) ==
- ({0: [1], 1: [2], 2: [3], 3: []}, {0: 3, 1: 2, 2: 1, 3: 0}))
+ ({0: [1], 1: [2], 2: [3], 3: []}, {0: 3, 1: 2, 2: 1, 3: 0}))
assert (nx.goldberg_radzik(G, 3) ==
- ({0: 1, 1: 2, 2: 3, 3: None}, {0: 3, 1: 2, 2: 1, 3: 0}))
+ ({0: 1, 1: 2, 2: 3, 3: None}, {0: 3, 1: 2, 2: 1, 3: 0}))
def test_4_cycle(self):
# 4-cycle
@@ -556,10 +556,10 @@ class TestBellmanFordAndGoldbergRadzik(WeightedTestBase):
def test_negative_weight(self):
G = nx.DiGraph()
G.add_nodes_from('abcd')
- G.add_edge('a','d', weight = 0)
- G.add_edge('a','b', weight = 1)
- G.add_edge('b','c', weight = -3)
- G.add_edge('c','d', weight = 1)
+ G.add_edge('a', 'd', weight=0)
+ G.add_edge('a', 'b', weight=1)
+ G.add_edge('b', 'c', weight=-3)
+ G.add_edge('c', 'd', weight=1)
assert nx.bellman_ford_path(G, 'a', 'd') == ['a', 'b', 'c', 'd']
assert nx.bellman_ford_path_length(G, 'a', 'd') == -1
@@ -592,10 +592,10 @@ class TestJohnsonAlgorithm(WeightedTestBase):
('2', '3', 1)])
paths = nx.johnson(G)
assert paths == {'1': {'1': ['1'], '3': ['1', '2', '3'],
- '2': ['1', '2']}, '0': {'1': ['0', '1'],
- '0': ['0'], '3': ['0', '1', '2', '3'],
- '2': ['0', '1', '2']}, '3': {'3': ['3']},
- '2': {'3': ['2', '3'], '2': ['2']}}
+ '2': ['1', '2']}, '0': {'1': ['0', '1'],
+ '0': ['0'], '3': ['0', '1', '2', '3'],
+ '2': ['0', '1', '2']}, '3': {'3': ['3']},
+ '2': {'3': ['2', '3'], '2': ['2']}}
def test_unweighted_graph(self):
with pytest.raises(nx.NetworkXError):
diff --git a/networkx/algorithms/similarity.py b/networkx/algorithms/similarity.py
index f558ba64..f0306c68 100644
--- a/networkx/algorithms/similarity.py
+++ b/networkx/algorithms/similarity.py
@@ -793,7 +793,6 @@ def optimize_edit_paths(G1, G2, node_match=None, edge_match=None,
yield from sorted(other, key=lambda t: t[4] + t[1].ls + t[3].ls)
-
def get_edit_paths(matched_uv, pending_u, pending_v, Cv,
matched_gh, pending_g, pending_h, Ce, matched_cost):
"""
@@ -826,15 +825,15 @@ def optimize_edit_paths(G1, G2, node_match=None, edge_match=None,
#debug_print('matched-cost:', matched_cost)
#debug_print('pending-u:', pending_u)
#debug_print('pending-v:', pending_v)
- #debug_print(Cv.C)
+ # debug_print(Cv.C)
#assert list(sorted(G1.nodes)) == list(sorted(list(u for u, v in matched_uv if u is not None) + pending_u))
#assert list(sorted(G2.nodes)) == list(sorted(list(v for u, v in matched_uv if v is not None) + pending_v))
#debug_print('pending-g:', pending_g)
#debug_print('pending-h:', pending_h)
- #debug_print(Ce.C)
+ # debug_print(Ce.C)
#assert list(sorted(G1.edges)) == list(sorted(list(g for g, h in matched_gh if g is not None) + pending_g))
#assert list(sorted(G2.edges)) == list(sorted(list(h for g, h in matched_gh if h is not None) + pending_h))
- #debug_print()
+ # debug_print()
if prune(matched_cost + Cv.ls + Ce.ls):
return
@@ -933,7 +932,7 @@ def optimize_edit_paths(G1, G2, node_match=None, edge_match=None,
).reshape(n, n)
Cv = make_CostMatrix(C, m, n)
#debug_print('Cv: {} x {}'.format(m, n))
- #debug_print(Cv.C)
+ # debug_print(Cv.C)
pending_g = list(G1.edges)
pending_h = list(G2.edges)
@@ -973,8 +972,8 @@ def optimize_edit_paths(G1, G2, node_match=None, edge_match=None,
).reshape(n, n)
Ce = make_CostMatrix(C, m, n)
#debug_print('Ce: {} x {}'.format(m, n))
- #debug_print(Ce.C)
- #debug_print()
+ # debug_print(Ce.C)
+ # debug_print()
class MaxCost:
def __init__(self):
diff --git a/networkx/algorithms/tests/test_boundary.py b/networkx/algorithms/tests/test_boundary.py
index ce64ae0b..8dbe3d69 100644
--- a/networkx/algorithms/tests/test_boundary.py
+++ b/networkx/algorithms/tests/test_boundary.py
@@ -109,13 +109,13 @@ class TestEdgeBoundary(object):
assert list(nx.edge_boundary(P10, [], [])) == []
assert list(nx.edge_boundary(P10, [1, 2, 3])) == [(3, 4)]
assert (sorted(nx.edge_boundary(P10, [4, 5, 6])) ==
- [(4, 3), (6, 7)])
+ [(4, 3), (6, 7)])
assert (sorted(nx.edge_boundary(P10, [3, 4, 5, 6, 7])) ==
- [(3, 2), (7, 8)])
+ [(3, 2), (7, 8)])
assert list(nx.edge_boundary(P10, [8, 9, 10])) == [(8, 7)]
assert sorted(nx.edge_boundary(P10, [4, 5, 6], [9, 10])) == []
assert (list(nx.edge_boundary(P10, [1, 2, 3], [3, 4, 5])) ==
- [(2, 3), (3, 4)])
+ [(2, 3), (3, 4)])
def test_complete_graph(self):
K10 = cnlti(nx.complete_graph(10), first_label=1)
diff --git a/networkx/algorithms/tests/test_chordal.py b/networkx/algorithms/tests/test_chordal.py
index e7719275..cb1bb82f 100644
--- a/networkx/algorithms/tests/test_chordal.py
+++ b/networkx/algorithms/tests/test_chordal.py
@@ -55,7 +55,7 @@ class TestMCS:
cliqueset = nx.chordal_graph_cliques(G)
for (u, v) in G.edges():
assert (frozenset([u, v]) in cliqueset
- or frozenset([v, u]) in cliqueset)
+ or frozenset([v, u]) in cliqueset)
def test_chordal_find_cliquesCC(self):
cliques = set([frozenset([1, 2, 3]), frozenset([2, 3, 4]),
diff --git a/networkx/algorithms/tests/test_clique.py b/networkx/algorithms/tests/test_clique.py
index 595015a9..e097c9bd 100644
--- a/networkx/algorithms/tests/test_clique.py
+++ b/networkx/algorithms/tests/test_clique.py
@@ -34,7 +34,7 @@ class TestCliques:
def test_find_cliques2(self):
hcl = list(nx.find_cliques(self.H))
assert (sorted(map(sorted, hcl)) ==
- [[1, 2], [1, 4, 5, 6], [2, 3], [3, 4, 6]])
+ [[1, 2], [1, 4, 5, 6], [2, 3], [3, 4, 6]])
def test_clique_number(self):
G = self.G
@@ -60,19 +60,19 @@ class TestCliques:
assert nx.number_of_cliques(G, [1, 2]) == {1: 1, 2: 2}
assert nx.number_of_cliques(G, 2) == 2
assert (nx.number_of_cliques(G) ==
- {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
- 6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
+ {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
+ 6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
assert (nx.number_of_cliques(G, nodes=list(G)) ==
- {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
- 6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
+ {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
+ 6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
assert (nx.number_of_cliques(G, nodes=[2, 3, 4]) ==
- {2: 2, 3: 1, 4: 2})
+ {2: 2, 3: 1, 4: 2})
assert (nx.number_of_cliques(G, cliques=self.cl) ==
- {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
- 6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
+ {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
+ 6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
assert (nx.number_of_cliques(G, list(G), cliques=self.cl) ==
- {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
- 6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
+ {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
+ 6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
def test_node_clique_number(self):
G = self.G
@@ -82,27 +82,27 @@ class TestCliques:
assert nx.node_clique_number(G, [1, 2]) == {1: 4, 2: 4}
assert nx.node_clique_number(G, 1) == 4
assert (nx.node_clique_number(G) ==
- {1: 4, 2: 4, 3: 4, 4: 3, 5: 3, 6: 4,
- 7: 3, 8: 2, 9: 2, 10: 2, 11: 2})
+ {1: 4, 2: 4, 3: 4, 4: 3, 5: 3, 6: 4,
+ 7: 3, 8: 2, 9: 2, 10: 2, 11: 2})
assert (nx.node_clique_number(G, cliques=self.cl) ==
- {1: 4, 2: 4, 3: 4, 4: 3, 5: 3, 6: 4,
- 7: 3, 8: 2, 9: 2, 10: 2, 11: 2})
+ {1: 4, 2: 4, 3: 4, 4: 3, 5: 3, 6: 4,
+ 7: 3, 8: 2, 9: 2, 10: 2, 11: 2})
def test_cliques_containing_node(self):
G = self.G
assert (nx.cliques_containing_node(G, 1) ==
- [[2, 6, 1, 3]])
+ [[2, 6, 1, 3]])
assert (list(nx.cliques_containing_node(G, [1]).values()) ==
- [[[2, 6, 1, 3]]])
+ [[[2, 6, 1, 3]]])
assert ([sorted(c) for c in list(nx.cliques_containing_node(G, [1, 2]).values())] ==
- [[[2, 6, 1, 3]], [[2, 6, 1, 3], [2, 6, 4]]])
+ [[[2, 6, 1, 3]], [[2, 6, 1, 3], [2, 6, 4]]])
result = nx.cliques_containing_node(G, [1, 2])
for k, v in result.items():
result[k] = sorted(v)
assert (result ==
- {1: [[2, 6, 1, 3]], 2: [[2, 6, 1, 3], [2, 6, 4]]})
+ {1: [[2, 6, 1, 3]], 2: [[2, 6, 1, 3], [2, 6, 4]]})
assert (nx.cliques_containing_node(G, 1) ==
- [[2, 6, 1, 3]])
+ [[2, 6, 1, 3]])
expected = [{2, 6, 1, 3}, {2, 6, 4}]
answer = [set(c) for c in nx.cliques_containing_node(G, 2)]
assert answer in (expected, list(reversed(expected)))
@@ -115,7 +115,7 @@ class TestCliques:
G = self.G
B = nx.make_clique_bipartite(G)
assert (sorted(B) ==
- [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
+ [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
# Project onto the nodes of the original graph.
H = nx.project(B, range(1, 12))
assert H.adj == G.adj
@@ -212,4 +212,4 @@ class TestEnumerateAllCliques:
['a', 'b', 'c', 'e']]
assert (sorted(map(sorted, cliques)) ==
- sorted(map(sorted, expected_cliques)))
+ sorted(map(sorted, expected_cliques)))
diff --git a/networkx/algorithms/tests/test_cluster.py b/networkx/algorithms/tests/test_cluster.py
index 2e76114c..f68957b8 100644
--- a/networkx/algorithms/tests/test_cluster.py
+++ b/networkx/algorithms/tests/test_cluster.py
@@ -11,15 +11,15 @@ class TestTriangles:
def test_path(self):
G = nx.path_graph(10)
assert (list(nx.triangles(G).values()) ==
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
+ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
assert (nx.triangles(G) ==
- {0: 0, 1: 0, 2: 0, 3: 0, 4: 0,
- 5: 0, 6: 0, 7: 0, 8: 0, 9: 0})
+ {0: 0, 1: 0, 2: 0, 3: 0, 4: 0,
+ 5: 0, 6: 0, 7: 0, 8: 0, 9: 0})
def test_cubical(self):
G = nx.cubical_graph()
assert (list(nx.triangles(G).values()) ==
- [0, 0, 0, 0, 0, 0, 0, 0])
+ [0, 0, 0, 0, 0, 0, 0, 0])
assert nx.triangles(G, 1) == 0
assert list(nx.triangles(G, [1, 2]).values()) == [0, 0]
assert nx.triangles(G, 1) == 0
@@ -45,10 +45,10 @@ class TestDirectedClustering:
def test_path(self):
G = nx.path_graph(10, create_using=nx.DiGraph())
assert (list(nx.clustering(G).values()) ==
- [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
+ [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
assert (nx.clustering(G) ==
- {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
- 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0})
+ {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
+ 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0})
def test_k5(self):
G = nx.complete_graph(5, create_using=nx.DiGraph())
@@ -56,11 +56,11 @@ class TestDirectedClustering:
assert nx.average_clustering(G) == 1
G.remove_edge(1, 2)
assert (list(nx.clustering(G).values()) ==
- [11. / 12., 1.0, 1.0, 11. / 12., 11. / 12.])
- assert nx.clustering(G, [1, 4]) == {1: 1.0, 4: 11. /12.}
+ [11. / 12., 1.0, 1.0, 11. / 12., 11. / 12.])
+ assert nx.clustering(G, [1, 4]) == {1: 1.0, 4: 11. / 12.}
G.remove_edge(2, 1)
assert (list(nx.clustering(G).values()) ==
- [5. / 6., 1.0, 1.0, 5. / 6., 5. / 6.])
+ [5. / 6., 1.0, 1.0, 5. / 6., 5. / 6.])
assert nx.clustering(G, [1, 4]) == {1: 1.0, 4: 0.83333333333333337}
def test_triangle_and_edge(self):
@@ -79,10 +79,10 @@ class TestDirectedWeightedClustering:
def test_path(self):
G = nx.path_graph(10, create_using=nx.DiGraph())
assert (list(nx.clustering(G, weight='weight').values()) ==
- [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
+ [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
assert (nx.clustering(G, weight='weight') ==
- {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
- 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0})
+ {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
+ 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0})
def test_k5(self):
G = nx.complete_graph(5, create_using=nx.DiGraph())
@@ -90,11 +90,11 @@ class TestDirectedWeightedClustering:
assert nx.average_clustering(G, weight='weight') == 1
G.remove_edge(1, 2)
assert (list(nx.clustering(G, weight='weight').values()) ==
- [11. / 12., 1.0, 1.0, 11. / 12., 11. / 12.])
- assert nx.clustering(G, [1, 4], weight='weight') == {1: 1.0, 4: 11. /12.}
+ [11. / 12., 1.0, 1.0, 11. / 12., 11. / 12.])
+ assert nx.clustering(G, [1, 4], weight='weight') == {1: 1.0, 4: 11. / 12.}
G.remove_edge(2, 1)
assert (list(nx.clustering(G, weight='weight').values()) ==
- [5. / 6., 1.0, 1.0, 5. / 6., 5. / 6.])
+ [5. / 6., 1.0, 1.0, 5. / 6., 5. / 6.])
assert nx.clustering(G, [1, 4], weight='weight') == {1: 1.0, 4: 0.83333333333333337}
def test_triangle_and_edge(self):
@@ -114,15 +114,15 @@ class TestWeightedClustering:
def test_path(self):
G = nx.path_graph(10)
assert (list(nx.clustering(G, weight='weight').values()) ==
- [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
+ [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
assert (nx.clustering(G, weight='weight') ==
- {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
- 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0})
+ {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
+ 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0})
def test_cubical(self):
G = nx.cubical_graph()
assert (list(nx.clustering(G, weight='weight').values()) ==
- [0, 0, 0, 0, 0, 0, 0, 0])
+ [0, 0, 0, 0, 0, 0, 0, 0])
assert nx.clustering(G, 1) == 0
assert list(nx.clustering(G, [1, 2], weight='weight').values()) == [0, 0]
assert nx.clustering(G, 1, weight='weight') == 0
@@ -134,7 +134,7 @@ class TestWeightedClustering:
assert nx.average_clustering(G, weight='weight') == 1
G.remove_edge(1, 2)
assert (list(nx.clustering(G, weight='weight').values()) ==
- [5. / 6., 1.0, 1.0, 5. / 6., 5. / 6.])
+ [5. / 6., 1.0, 1.0, 5. / 6., 5. / 6.])
assert nx.clustering(G, [1, 4], weight='weight') == {1: 1.0, 4: 0.83333333333333337}
def test_triangle_and_edge(self):
@@ -154,15 +154,15 @@ class TestClustering:
def test_path(self):
G = nx.path_graph(10)
assert (list(nx.clustering(G).values()) ==
- [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
+ [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
assert (nx.clustering(G) ==
- {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
- 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0})
+ {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
+ 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0})
def test_cubical(self):
G = nx.cubical_graph()
assert (list(nx.clustering(G).values()) ==
- [0, 0, 0, 0, 0, 0, 0, 0])
+ [0, 0, 0, 0, 0, 0, 0, 0])
assert nx.clustering(G, 1) == 0
assert list(nx.clustering(G, [1, 2]).values()) == [0, 0]
assert nx.clustering(G, 1) == 0
@@ -174,7 +174,7 @@ class TestClustering:
assert nx.average_clustering(G) == 1
G.remove_edge(1, 2)
assert (list(nx.clustering(G).values()) ==
- [5. / 6., 1.0, 1.0, 5. / 6., 5. / 6.])
+ [5. / 6., 1.0, 1.0, 5. / 6., 5. / 6.])
assert nx.clustering(G, [1, 4]) == {1: 1.0, 4: 0.83333333333333337}
@@ -209,15 +209,15 @@ class TestSquareClustering:
def test_path(self):
G = nx.path_graph(10)
assert (list(nx.square_clustering(G).values()) ==
- [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
+ [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
assert (nx.square_clustering(G) ==
- {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
- 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0})
+ {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
+ 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0})
def test_cubical(self):
G = nx.cubical_graph()
assert (list(nx.square_clustering(G).values()) ==
- [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5])
+ [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5])
assert list(nx.square_clustering(G, [1, 2]).values()) == [0.5, 0.5]
assert nx.square_clustering(G, [1])[1] == 0.5
assert nx.square_clustering(G, [1, 2]) == {1: 0.5, 2: 0.5}
@@ -229,7 +229,7 @@ class TestSquareClustering:
def test_bipartite_k5(self):
G = nx.complete_bipartite_graph(5, 5)
assert (list(nx.square_clustering(G).values()) ==
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
+ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
def test_lind_square_clustering(self):
"""Test C4 for figure 1 Lind et al (2005)"""
diff --git a/networkx/algorithms/tests/test_core.py b/networkx/algorithms/tests/test_core.py
index 585ca6b2..52d1444b 100644
--- a/networkx/algorithms/tests/test_core.py
+++ b/networkx/algorithms/tests/test_core.py
@@ -128,16 +128,16 @@ class TestCore:
def test_k_truss(self):
# k=-1
k_truss_subgraph = nx.k_truss(self.G, -1)
- assert sorted(k_truss_subgraph.nodes()) == list(range(1,21))
+ assert sorted(k_truss_subgraph.nodes()) == list(range(1, 21))
# k=0
k_truss_subgraph = nx.k_truss(self.G, 0)
- assert sorted(k_truss_subgraph.nodes()) == list(range(1,21))
+ assert sorted(k_truss_subgraph.nodes()) == list(range(1, 21))
# k=1
k_truss_subgraph = nx.k_truss(self.G, 1)
- assert sorted(k_truss_subgraph.nodes()) == list(range(1,13))
+ assert sorted(k_truss_subgraph.nodes()) == list(range(1, 13))
# k=2
k_truss_subgraph = nx.k_truss(self.G, 2)
- assert sorted(k_truss_subgraph.nodes()) == list(range(1,9))
+ assert sorted(k_truss_subgraph.nodes()) == list(range(1, 9))
# k=3
k_truss_subgraph = nx.k_truss(self.G, 3)
assert sorted(k_truss_subgraph.nodes()) == []
diff --git a/networkx/algorithms/tests/test_cycles.py b/networkx/algorithms/tests/test_cycles.py
index 003f660a..c8344715 100644
--- a/networkx/algorithms/tests/test_cycles.py
+++ b/networkx/algorithms/tests/test_cycles.py
@@ -43,7 +43,7 @@ class TestCycles:
cy = networkx.cycle_basis(G, 9)
sort_cy = sorted(sorted(c) for c in cy[:-1]) + [sorted(cy[-1])]
assert sort_cy == [[0, 1, 2, 3], [0, 1, 6, 7, 8], [0, 3, 4, 5],
- ['A', 'B', 'C']]
+ ['A', 'B', 'C']]
def test_cycle_basis(self):
with pytest.raises(nx.NetworkXNotImplemented):
diff --git a/networkx/algorithms/tests/test_dag.py b/networkx/algorithms/tests/test_dag.py
index bb841c93..93231c46 100644
--- a/networkx/algorithms/tests/test_dag.py
+++ b/networkx/algorithms/tests/test_dag.py
@@ -203,11 +203,11 @@ class TestDAG:
def test_all_topological_sorts_2(self):
DG = nx.DiGraph([(1, 3), (2, 1), (2, 4), (4, 3), (4, 5)])
assert (sorted(nx.all_topological_sorts(DG)) ==
- [[2, 1, 4, 3, 5],
- [2, 1, 4, 5, 3],
- [2, 4, 1, 3, 5],
- [2, 4, 1, 5, 3],
- [2, 4, 5, 1, 3]])
+ [[2, 1, 4, 3, 5],
+ [2, 1, 4, 5, 3],
+ [2, 4, 1, 3, 5],
+ [2, 4, 1, 5, 3],
+ [2, 4, 5, 1, 3]])
def test_all_topological_sorts_3(self):
def unfeasible():
@@ -232,14 +232,14 @@ class TestDAG:
for i in range(7):
DG.add_node(i)
assert (sorted(map(list, permutations(DG.nodes))) ==
- sorted(nx.all_topological_sorts(DG)))
+ sorted(nx.all_topological_sorts(DG)))
def test_all_topological_sorts_multigraph_1(self):
DG = nx.MultiDiGraph([(1, 2), (1, 2), (2, 3),
(3, 4), (3, 5), (3, 5), (3, 5)])
assert (sorted(nx.all_topological_sorts(DG)) ==
- sorted([[1, 2, 3, 4, 5],
- [1, 2, 3, 5, 4]]))
+ sorted([[1, 2, 3, 4, 5],
+ [1, 2, 3, 5, 4]]))
def test_all_topological_sorts_multigraph_2(self):
N = 9
@@ -248,7 +248,7 @@ class TestDAG:
edges.extend([(i, i+1)] * i)
DG = nx.MultiDiGraph(edges)
assert (list(nx.all_topological_sorts(DG)) ==
- [list(range(1, N+1))])
+ [list(range(1, N+1))])
def test_ancestors(self):
G = nx.DiGraph()
@@ -393,7 +393,7 @@ class TestDAG:
def test_lexicographical_topological_sort(self):
G = nx.DiGraph([(1, 2), (2, 3), (1, 4), (1, 5), (2, 6)])
assert (list(nx.lexicographical_topological_sort(G)) ==
- [1, 2, 3, 4, 5, 6])
+ [1, 2, 3, 4, 5, 6])
assert (list(nx.lexicographical_topological_sort(
G, key=lambda x: x)) ==
[1, 2, 3, 4, 5, 6])
diff --git a/networkx/algorithms/tests/test_distance_measures.py b/networkx/algorithms/tests/test_distance_measures.py
index 49e4569b..0a402070 100644
--- a/networkx/algorithms/tests/test_distance_measures.py
+++ b/networkx/algorithms/tests/test_distance_measures.py
@@ -112,10 +112,10 @@ class TestResistanceDistance:
def test_laplacian_submatrix(self):
from networkx.algorithms.distance_measures import _laplacian_submatrix
M = sp_sparse.csr_matrix([[1, 2, 3],
- [4, 5, 6],
- [7, 8, 9]], dtype=np.float32)
+ [4, 5, 6],
+ [7, 8, 9]], dtype=np.float32)
N = sp_sparse.csr_matrix([[5, 6],
- [8, 9]], dtype=np.float32)
+ [8, 9]], dtype=np.float32)
Mn, Mn_nodelist = _laplacian_submatrix(1, M, [1, 2, 3])
assert Mn_nodelist == [2, 3]
assert np.allclose(Mn.toarray(), N.toarray())
@@ -124,16 +124,16 @@ class TestResistanceDistance:
with pytest.raises(nx.NetworkXError):
from networkx.algorithms.distance_measures import _laplacian_submatrix
M = sp_sparse.csr_matrix([[1, 2],
- [4, 5],
- [7, 8]], dtype=np.float32)
+ [4, 5],
+ [7, 8]], dtype=np.float32)
_laplacian_submatrix(1, M, [1, 2, 3])
def test_laplacian_submatrix_matrix_node_dim(self):
with pytest.raises(nx.NetworkXError):
from networkx.algorithms.distance_measures import _laplacian_submatrix
M = sp_sparse.csr_matrix([[1, 2, 3],
- [4, 5, 6],
- [7, 8, 9]], dtype=np.float32)
+ [4, 5, 6],
+ [7, 8, 9]], dtype=np.float32)
_laplacian_submatrix(1, M, [1, 2, 3, 4])
def test_resistance_distance(self):
diff --git a/networkx/algorithms/tests/test_dominance.py b/networkx/algorithms/tests/test_dominance.py
index 5f1f36fb..218d8081 100644
--- a/networkx/algorithms/tests/test_dominance.py
+++ b/networkx/algorithms/tests/test_dominance.py
@@ -24,20 +24,20 @@ class TestImmediateDominators(object):
n = 5
G = nx.path_graph(n, create_using=nx.DiGraph())
assert (nx.immediate_dominators(G, 0) ==
- {i: max(i - 1, 0) for i in range(n)})
+ {i: max(i - 1, 0) for i in range(n)})
def test_cycle(self):
n = 5
G = nx.cycle_graph(n, create_using=nx.DiGraph())
assert (nx.immediate_dominators(G, 0) ==
- {i: max(i - 1, 0) for i in range(n)})
+ {i: max(i - 1, 0) for i in range(n)})
def test_unreachable(self):
n = 5
assert n > 1
G = nx.path_graph(n, create_using=nx.DiGraph())
assert (nx.immediate_dominators(G, n // 2) ==
- {i: max(i - 1, n // 2) for i in range(n // 2, n)})
+ {i: max(i - 1, n // 2) for i in range(n // 2, n)})
def test_irreducible1(self):
# Graph taken from Figure 2 of
@@ -47,7 +47,7 @@ class TestImmediateDominators(object):
edges = [(1, 2), (2, 1), (3, 2), (4, 1), (5, 3), (5, 4)]
G = nx.DiGraph(edges)
assert (nx.immediate_dominators(G, 5) ==
- {i: 5 for i in range(1, 6)})
+ {i: 5 for i in range(1, 6)})
def test_irreducible2(self):
# Graph taken from Figure 4 of
@@ -58,18 +58,18 @@ class TestImmediateDominators(object):
(6, 4), (6, 5)]
G = nx.DiGraph(edges)
assert (nx.immediate_dominators(G, 6) ==
- {i: 6 for i in range(1, 7)})
+ {i: 6 for i in range(1, 7)})
def test_domrel_png(self):
# Graph taken from https://commons.wikipedia.org/wiki/File:Domrel.png
edges = [(1, 2), (2, 3), (2, 4), (2, 6), (3, 5), (4, 5), (5, 2)]
G = nx.DiGraph(edges)
assert (nx.immediate_dominators(G, 1) ==
- {1: 1, 2: 1, 3: 2, 4: 2, 5: 2, 6: 2})
+ {1: 1, 2: 1, 3: 2, 4: 2, 5: 2, 6: 2})
# Test postdominance.
with nx.utils.reversed(G):
assert (nx.immediate_dominators(G, 6) ==
- {1: 2, 2: 6, 3: 5, 4: 5, 5: 2, 6: 6})
+ {1: 2, 2: 6, 3: 5, 4: 5, 5: 2, 6: 6})
def test_boost_example(self):
# Graph taken from Figure 1 of
@@ -78,11 +78,11 @@ class TestImmediateDominators(object):
(5, 7), (6, 4)]
G = nx.DiGraph(edges)
assert (nx.immediate_dominators(G, 0) ==
- {0: 0, 1: 0, 2: 1, 3: 1, 4: 3, 5: 4, 6: 4, 7: 1})
+ {0: 0, 1: 0, 2: 1, 3: 1, 4: 3, 5: 4, 6: 4, 7: 1})
# Test postdominance.
with nx.utils.reversed(G):
assert (nx.immediate_dominators(G, 7) ==
- {0: 1, 1: 7, 2: 7, 3: 4, 4: 5, 5: 7, 6: 4, 7: 7})
+ {0: 1, 1: 7, 2: 7, 3: 4, 4: 5, 5: 7, 6: 4, 7: 7})
class TestDominanceFrontiers(object):
@@ -107,20 +107,20 @@ class TestDominanceFrontiers(object):
n = 5
G = nx.path_graph(n, create_using=nx.DiGraph())
assert (nx.dominance_frontiers(G, 0) ==
- {i: set() for i in range(n)})
+ {i: set() for i in range(n)})
def test_cycle(self):
n = 5
G = nx.cycle_graph(n, create_using=nx.DiGraph())
assert (nx.dominance_frontiers(G, 0) ==
- {i: set() for i in range(n)})
+ {i: set() for i in range(n)})
def test_unreachable(self):
n = 5
assert n > 1
G = nx.path_graph(n, create_using=nx.DiGraph())
assert (nx.dominance_frontiers(G, n // 2) ==
- {i: set() for i in range(n // 2, n)})
+ {i: set() for i in range(n // 2, n)})
def test_irreducible1(self):
# Graph taken from Figure 2 of
@@ -130,9 +130,9 @@ class TestDominanceFrontiers(object):
edges = [(1, 2), (2, 1), (3, 2), (4, 1), (5, 3), (5, 4)]
G = nx.DiGraph(edges)
assert ({u: df
- for u, df in nx.dominance_frontiers(G, 5).items()} ==
- {1: set([2]), 2: set([1]), 3: set([2]),
- 4: set([1]), 5: set()})
+ for u, df in nx.dominance_frontiers(G, 5).items()} ==
+ {1: set([2]), 2: set([1]), 3: set([2]),
+ 4: set([1]), 5: set()})
def test_irreducible2(self):
# Graph taken from Figure 4 of
@@ -143,20 +143,20 @@ class TestDominanceFrontiers(object):
(6, 4), (6, 5)]
G = nx.DiGraph(edges)
assert (nx.dominance_frontiers(G, 6) ==
- {1: set([2]), 2: set([1, 3]), 3: set([2]), 4: set([2, 3]), 5: set([1]), 6: set([])})
+ {1: set([2]), 2: set([1, 3]), 3: set([2]), 4: set([2, 3]), 5: set([1]), 6: set([])})
def test_domrel_png(self):
# Graph taken from https://commons.wikipedia.org/wiki/File:Domrel.png
edges = [(1, 2), (2, 3), (2, 4), (2, 6), (3, 5), (4, 5), (5, 2)]
G = nx.DiGraph(edges)
assert (nx.dominance_frontiers(G, 1) ==
- {1: set([]), 2: set([2]), 3: set([5]), 4: set([5]),
- 5: set([2]), 6: set()})
+ {1: set([]), 2: set([2]), 3: set([5]), 4: set([5]),
+ 5: set([2]), 6: set()})
# Test postdominance.
with nx.utils.reversed(G):
assert (nx.dominance_frontiers(G, 6) ==
- {1: set(), 2: set([2]), 3: set([2]), 4: set([2]),
- 5: set([2]), 6: set()})
+ {1: set(), 2: set([2]), 3: set([2]), 4: set([2]),
+ 5: set([2]), 6: set()})
def test_boost_example(self):
# Graph taken from Figure 1 of
@@ -165,13 +165,13 @@ class TestDominanceFrontiers(object):
(5, 7), (6, 4)]
G = nx.DiGraph(edges)
assert (nx.dominance_frontiers(G, 0) ==
- {0: set(), 1: set(), 2: set([7]), 3: set([7]),
- 4: set([4, 7]), 5: set([7]), 6: set([4]), 7: set()})
+ {0: set(), 1: set(), 2: set([7]), 3: set([7]),
+ 4: set([4, 7]), 5: set([7]), 6: set([4]), 7: set()})
# Test postdominance.
with nx.utils.reversed(G):
assert (nx.dominance_frontiers(G, 7) ==
- {0: set(), 1: set(), 2: set([1]), 3: set([1]),
- 4: set([1, 4]), 5: set([1]), 6: set([4]), 7: set()})
+ {0: set(), 1: set(), 2: set([1]), 3: set([1]),
+ 4: set([1, 4]), 5: set([1]), 6: set([4]), 7: set()})
def test_discard_issue(self):
# https://github.com/networkx/networkx/issues/2071
@@ -192,9 +192,9 @@ class TestDominanceFrontiers(object):
)
df = nx.dominance_frontiers(g, 'b0')
assert df == {'b4': set(), 'b5': set(['b3']), 'b6': set(['b7']),
- 'b7': set(['b3']),
- 'b0': set(), 'b1': set(['b1']), 'b2': set(['b3']),
- 'b3': set(['b1']), 'b8': set(['b7'])}
+ 'b7': set(['b3']),
+ 'b0': set(), 'b1': set(['b1']), 'b2': set(['b3']),
+ 'b3': set(['b1']), 'b8': set(['b7'])}
def test_loop(self):
g = nx.DiGraph()
diff --git a/networkx/algorithms/tests/test_link_prediction.py b/networkx/algorithms/tests/test_link_prediction.py
index 3cb9b602..5c8fa4d7 100644
--- a/networkx/algorithms/tests/test_link_prediction.py
+++ b/networkx/algorithms/tests/test_link_prediction.py
@@ -36,11 +36,11 @@ class TestResourceAllocationIndex():
def test_notimplemented(self):
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)])
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.MultiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.MultiGraph([(0, 1), (1, 2)]), [(0, 2)])
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.MultiDiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.MultiDiGraph([(0, 1), (1, 2)]), [(0, 2)])
def test_no_common_neighbor(self):
G = nx.Graph()
@@ -73,11 +73,11 @@ class TestJaccardCoefficient():
def test_notimplemented(self):
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)])
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.MultiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.MultiGraph([(0, 1), (1, 2)]), [(0, 2)])
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.MultiDiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.MultiDiGraph([(0, 1), (1, 2)]), [(0, 2)])
def test_no_common_neighbor(self):
G = nx.Graph()
@@ -115,11 +115,11 @@ class TestAdamicAdarIndex():
def test_notimplemented(self):
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)])
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.MultiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.MultiGraph([(0, 1), (1, 2)]), [(0, 2)])
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.MultiDiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.MultiDiGraph([(0, 1), (1, 2)]), [(0, 2)])
def test_no_common_neighbor(self):
G = nx.Graph()
@@ -157,11 +157,11 @@ class TestPreferentialAttachment():
def test_notimplemented(self):
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)])
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.MultiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.MultiGraph([(0, 1), (1, 2)]), [(0, 2)])
assert pytest.raises(nx.NetworkXNotImplemented, self.func,
- nx.MultiDiGraph([(0, 1), (1, 2)]), [(0, 2)])
+ nx.MultiDiGraph([(0, 1), (1, 2)]), [(0, 2)])
def test_zero_degrees(self):
G = nx.Graph()
@@ -179,7 +179,7 @@ class TestCNSoundarajanHopcroft():
def setup_class(cls):
cls.func = staticmethod(nx.cn_soundarajan_hopcroft)
cls.test = partial(_test_func, predict_func=cls.func,
- community='community')
+ community='community')
def test_K5(self):
G = nx.complete_graph(5)
@@ -392,7 +392,7 @@ class TestWithinInterCluster():
cls.delta = 0.001
cls.func = staticmethod(nx.within_inter_cluster)
cls.test = partial(_test_func, predict_func=cls.func,
- delta=cls.delta, community='community')
+ delta=cls.delta, community='community')
def test_K5(self):
G = nx.complete_graph(5)
diff --git a/networkx/algorithms/tests/test_lowest_common_ancestors.py b/networkx/algorithms/tests/test_lowest_common_ancestors.py
index c5b4ef03..b8ca9549 100644
--- a/networkx/algorithms/tests/test_lowest_common_ancestors.py
+++ b/networkx/algorithms/tests/test_lowest_common_ancestors.py
@@ -167,41 +167,41 @@ class TestDAGLCA:
cls.root_distance = nx.shortest_path_length(cls.DG, source=0)
cls.gold = {(1, 1): 1,
- (1, 2): 1,
- (1, 3): 1,
- (1, 4): 0,
- (1, 5): 0,
- (1, 6): 0,
- (1, 7): 0,
- (1, 8): 0,
- (2, 2): 2,
- (2, 3): 2,
- (2, 4): 0,
- (2, 5): 5,
- (2, 6): 6,
- (2, 7): 7,
- (2, 8): 7,
- (3, 3): 8,
- (3, 4): 4,
- (3, 5): 5,
- (3, 6): 6,
- (3, 7): 7,
- (3, 8): 8,
- (4, 4): 4,
- (4, 5): 0,
- (4, 6): 0,
- (4, 7): 0,
- (4, 8): 0,
- (5, 5): 5,
- (5, 6): 5,
- (5, 7): 5,
- (5, 8): 5,
- (6, 6): 6,
- (6, 7): 5,
- (6, 8): 6,
- (7, 7): 7,
- (7, 8): 7,
- (8, 8): 8}
+ (1, 2): 1,
+ (1, 3): 1,
+ (1, 4): 0,
+ (1, 5): 0,
+ (1, 6): 0,
+ (1, 7): 0,
+ (1, 8): 0,
+ (2, 2): 2,
+ (2, 3): 2,
+ (2, 4): 0,
+ (2, 5): 5,
+ (2, 6): 6,
+ (2, 7): 7,
+ (2, 8): 7,
+ (3, 3): 8,
+ (3, 4): 4,
+ (3, 5): 5,
+ (3, 6): 6,
+ (3, 7): 7,
+ (3, 8): 8,
+ (4, 4): 4,
+ (4, 5): 0,
+ (4, 6): 0,
+ (4, 7): 0,
+ (4, 8): 0,
+ (5, 5): 5,
+ (5, 6): 5,
+ (5, 7): 5,
+ (5, 8): 5,
+ (6, 6): 6,
+ (6, 7): 5,
+ (6, 8): 6,
+ (7, 7): 7,
+ (7, 8): 7,
+ (8, 8): 8}
cls.gold.update(((0, n), 0) for n in cls.DG)
def assert_lca_dicts_same(self, d1, d2, G=None):
@@ -218,7 +218,7 @@ class TestDAGLCA:
for a, b in ((min(pair), max(pair)) for pair in chain(d1, d2)):
assert (root_distance[get_pair(d1, a, b)] ==
- root_distance[get_pair(d2, a, b)])
+ root_distance[get_pair(d2, a, b)])
def test_all_pairs_lowest_common_ancestor1(self):
"""Produces the correct results."""
@@ -297,7 +297,7 @@ class TestDAGLCA:
G = nx.DiGraph([(0, 1), (2, 1)])
sentinel = object()
assert (nx.lowest_common_ancestor(G, 0, 2, default=sentinel) is
- sentinel)
+ sentinel)
def test_lowest_common_ancestor2(self):
"""Test that the one-pair function works on identity."""
diff --git a/networkx/algorithms/tests/test_mis.py b/networkx/algorithms/tests/test_mis.py
index eb36fd3b..8f27f7e0 100644
--- a/networkx/algorithms/tests/test_mis.py
+++ b/networkx/algorithms/tests/test_mis.py
@@ -77,8 +77,8 @@ class TestMaximalIndependantSet(object):
G = self.florentine
indep = nx.maximal_independent_set(G, ["Medici", "Bischeri"])
assert (sorted(indep) ==
- sorted(["Medici", "Bischeri", "Castellani", "Pazzi",
- "Ginori", "Lamberteschi"]))
+ sorted(["Medici", "Bischeri", "Castellani", "Pazzi",
+ "Ginori", "Lamberteschi"]))
def test_bipartite(self):
G = nx.complete_bipartite_graph(12, 34)
diff --git a/networkx/algorithms/tests/test_moral.py b/networkx/algorithms/tests/test_moral.py
index c9f4de94..dee4949b 100644
--- a/networkx/algorithms/tests/test_moral.py
+++ b/networkx/algorithms/tests/test_moral.py
@@ -3,7 +3,6 @@ import networkx as nx
from networkx.algorithms.moral import moral_graph
-
def test_get_moral_graph():
graph = nx.DiGraph()
graph.add_nodes_from([1, 2, 3, 4, 5, 6, 7])
diff --git a/networkx/algorithms/tests/test_planar_drawing.py b/networkx/algorithms/tests/test_planar_drawing.py
index d9100d19..ee9fe5cf 100644
--- a/networkx/algorithms/tests/test_planar_drawing.py
+++ b/networkx/algorithms/tests/test_planar_drawing.py
@@ -107,7 +107,7 @@ def check_embedding_data(embedding_data):
msg = "Planar drawing does not conform to the embedding (internal " \
"triangulation)"
assert planar_drawing_conforms_to_embedding(embedding,
- pos_internally), msg
+ pos_internally), msg
check_edge_intersections(embedding, pos_internally)
diff --git a/networkx/algorithms/tests/test_richclub.py b/networkx/algorithms/tests/test_richclub.py
index a55ffd27..e2eb02e4 100644
--- a/networkx/algorithms/tests/test_richclub.py
+++ b/networkx/algorithms/tests/test_richclub.py
@@ -28,8 +28,8 @@ def test_richclub2():
T = nx.balanced_tree(2, 10)
rc = nx.richclub.rich_club_coefficient(T, normalized=False)
assert rc == {0: 4092 / (2047 * 2046.0),
- 1: (2044.0 / (1023 * 1022)),
- 2: (2040.0 / (1022 * 1021))}
+ 1: (2044.0 / (1023 * 1022)),
+ 2: (2040.0 / (1022 * 1021))}
def test_richclub3():
@@ -37,21 +37,21 @@ def test_richclub3():
G = nx.karate_club_graph()
rc = nx.rich_club_coefficient(G, normalized=False)
assert rc == {0: 156.0 / 1122,
- 1: 154.0 / 1056,
- 2: 110.0 / 462,
- 3: 78.0 / 240,
- 4: 44.0 / 90,
- 5: 22.0 / 42,
- 6: 10.0 / 20,
- 7: 10.0 / 20,
- 8: 10.0 / 20,
- 9: 6.0 / 12,
- 10: 2.0 / 6,
- 11: 2.0 / 6,
- 12: 0.0,
- 13: 0.0,
- 14: 0.0,
- 15: 0.0, }
+ 1: 154.0 / 1056,
+ 2: 110.0 / 462,
+ 3: 78.0 / 240,
+ 4: 44.0 / 90,
+ 5: 22.0 / 42,
+ 6: 10.0 / 20,
+ 7: 10.0 / 20,
+ 8: 10.0 / 20,
+ 9: 6.0 / 12,
+ 10: 2.0 / 6,
+ 11: 2.0 / 6,
+ 12: 0.0,
+ 13: 0.0,
+ 14: 0.0,
+ 15: 0.0, }
def test_richclub4():
@@ -59,9 +59,9 @@ def test_richclub4():
G.add_edges_from([(0, 1), (0, 2), (0, 3), (0, 4), (4, 5), (5, 9), (6, 9), (7, 9), (8, 9)])
rc = nx.rich_club_coefficient(G, normalized=False)
assert rc == {0: 18 / 90.0,
- 1: 6 / 12.0,
- 2: 0.0,
- 3: 0.0}
+ 1: 6 / 12.0,
+ 2: 0.0,
+ 3: 0.0}
def test_richclub_exception():
diff --git a/networkx/algorithms/tests/test_similarity.py b/networkx/algorithms/tests/test_similarity.py
index b43bff86..a2c5d5ac 100644
--- a/networkx/algorithms/tests/test_similarity.py
+++ b/networkx/algorithms/tests/test_similarity.py
@@ -9,9 +9,11 @@ from networkx.generators.classic import *
def nmatch(n1, n2):
return n1 == n2
+
def ematch(e1, e2):
return e1 == e2
+
def getCanonical():
G = nx.Graph()
G.add_node('A', label='A')
@@ -106,9 +108,9 @@ class TestSimilarity:
return 100
assert graph_edit_distance(G1, G2,
- node_subst_cost=node_subst_cost,
- node_del_cost=node_del_cost,
- node_ins_cost=node_ins_cost) == 6
+ node_subst_cost=node_subst_cost,
+ node_del_cost=node_del_cost,
+ node_ins_cost=node_ins_cost) == 6
def test_graph_edit_distance_edge_cost(self):
G1 = path_graph(6)
@@ -137,9 +139,9 @@ class TestSimilarity:
return 1.0
assert graph_edit_distance(G1, G2,
- edge_subst_cost=edge_subst_cost,
- edge_del_cost=edge_del_cost,
- edge_ins_cost=edge_ins_cost) == 0.23
+ edge_subst_cost=edge_subst_cost,
+ edge_del_cost=edge_del_cost,
+ edge_ins_cost=edge_ins_cost) == 0.23
def test_graph_edit_distance_upper_bound(self):
G1 = circular_ladder_graph(2)
@@ -165,7 +167,7 @@ class TestSimilarity:
([(0, 2), (1, 0), (2, 1)], [((0, 1), (0, 2)), ((1, 2), (0, 1)), (None, (1, 2))]),
([(0, 2), (1, 1), (2, 0)], [((0, 1), (1, 2)), ((1, 2), (0, 1)), (None, (0, 2))])]
assert (set(canonical(*p) for p in paths) ==
- set(canonical(*p) for p in expected_paths))
+ set(canonical(*p) for p in expected_paths))
def test_optimize_graph_edit_distance(self):
G1 = circular_ladder_graph(2)
diff --git a/networkx/algorithms/tests/test_simple_paths.py b/networkx/algorithms/tests/test_simple_paths.py
index 52993c9c..5ef3248c 100644
--- a/networkx/algorithms/tests/test_simple_paths.py
+++ b/networkx/algorithms/tests/test_simple_paths.py
@@ -245,7 +245,7 @@ def test_shortest_simple_paths():
assert next(paths) == [1, 2, 3, 4, 8, 12]
assert next(paths) == [1, 5, 6, 7, 8, 12]
assert ([len(path) for path in nx.shortest_simple_paths(G, 1, 12)] ==
- sorted([len(path) for path in nx.all_simple_paths(G, 1, 12)]))
+ sorted([len(path) for path in nx.all_simple_paths(G, 1, 12)]))
def test_shortest_simple_paths_directed():
@@ -304,14 +304,14 @@ def test_weighted_shortest_simple_path_issue2427():
G.add_edge('IN', 'B', weight=2)
G.add_edge('B', 'OUT', weight=2)
assert (list(nx.shortest_simple_paths(G, 'IN', 'OUT', weight="weight")) ==
- [['IN', 'OUT'], ['IN', 'B', 'OUT']])
+ [['IN', 'OUT'], ['IN', 'B', 'OUT']])
G = nx.Graph()
G.add_edge('IN', 'OUT', weight=10)
G.add_edge('IN', 'A', weight=1)
G.add_edge('IN', 'B', weight=1)
G.add_edge('B', 'OUT', weight=1)
assert (list(nx.shortest_simple_paths(G, 'IN', 'OUT', weight="weight")) ==
- [['IN', 'B', 'OUT'], ['IN', 'OUT']])
+ [['IN', 'B', 'OUT'], ['IN', 'OUT']])
def test_directed_weighted_shortest_simple_path_issue2427():
@@ -321,14 +321,14 @@ def test_directed_weighted_shortest_simple_path_issue2427():
G.add_edge('IN', 'B', weight=2)
G.add_edge('B', 'OUT', weight=2)
assert (list(nx.shortest_simple_paths(G, 'IN', 'OUT', weight="weight")) ==
- [['IN', 'OUT'], ['IN', 'B', 'OUT']])
+ [['IN', 'OUT'], ['IN', 'B', 'OUT']])
G = nx.DiGraph()
G.add_edge('IN', 'OUT', weight=10)
G.add_edge('IN', 'A', weight=1)
G.add_edge('IN', 'B', weight=1)
G.add_edge('B', 'OUT', weight=1)
assert (list(nx.shortest_simple_paths(G, 'IN', 'OUT', weight="weight")) ==
- [['IN', 'B', 'OUT'], ['IN', 'OUT']])
+ [['IN', 'B', 'OUT'], ['IN', 'OUT']])
def test_weight_name():
@@ -450,7 +450,7 @@ def validate_path(G, s, t, soln_len, path):
assert path[0] == s
assert path[-1] == t
assert soln_len == sum(G[u][v].get('weight', 1)
- for u, v in zip(path[:-1], path[1:]))
+ for u, v in zip(path[:-1], path[1:]))
def validate_length_path(G, s, t, soln_len, length, path):
diff --git a/networkx/algorithms/tests/test_swap.py b/networkx/algorithms/tests/test_swap.py
index cde16c22..8a1afaa9 100644
--- a/networkx/algorithms/tests/test_swap.py
+++ b/networkx/algorithms/tests/test_swap.py
@@ -3,7 +3,7 @@ import pytest
import networkx as nx
#import random
-#random.seed(0)
+# random.seed(0)
def test_double_edge_swap():
diff --git a/networkx/algorithms/tests/test_threshold.py b/networkx/algorithms/tests/test_threshold.py
index dbf0a726..f28d9371 100644
--- a/networkx/algorithms/tests/test_threshold.py
+++ b/networkx/algorithms/tests/test_threshold.py
@@ -65,7 +65,7 @@ class TestGeneratorThreshold():
assert nxt.uncompact([3, 1, 2]) == ['d', 'd', 'd', 'i', 'd', 'd']
assert nxt.uncompact(['d', 'd', 'i', 'd']) == ['d', 'd', 'i', 'd']
assert (nxt.uncompact(nxt.uncompact([(1, 'd'), (2, 'd'), (3, 'i'), (0, 'd')])) ==
- nxt.uncompact([(1, 'd'), (2, 'd'), (3, 'i'), (0, 'd')]))
+ nxt.uncompact([(1, 'd'), (2, 'd'), (3, 'i'), (0, 'd')]))
assert pytest.raises(TypeError, nxt.uncompact, [3., 1., 2.])
def test_creation_sequence_to_weights(self):
@@ -77,7 +77,7 @@ class TestGeneratorThreshold():
with pytest.raises(ValueError):
nxt.weights_to_creation_sequence(deg, with_labels=True, compact=True)
assert (nxt.weights_to_creation_sequence(deg, with_labels=True) ==
- [(3, 'd'), (1, 'd'), (2, 'd'), (0, 'd')])
+ [(3, 'd'), (1, 'd'), (2, 'd'), (0, 'd')])
assert nxt.weights_to_creation_sequence(deg, compact=True) == [4]
def test_find_alternating_4_cycle(self):
@@ -92,7 +92,7 @@ class TestGeneratorThreshold():
for n, m in [(3, 0), (0, 3), (0, 2), (0, 1), (1, 3),
(3, 1), (1, 2), (2, 3)]:
assert (nxt.shortest_path(cs1, n, m) ==
- nx.shortest_path(G, n, m))
+ nx.shortest_path(G, n, m))
spl = nxt.shortest_path_length(cs1, 3)
spl2 = nxt.shortest_path_length([t for v, t in cs1], 2)
@@ -114,15 +114,15 @@ class TestGeneratorThreshold():
def test_shortest_path_length(self):
assert nxt.shortest_path_length([3, 1, 2], 1) == [1, 0, 1, 2, 1, 1]
assert (nxt.shortest_path_length(['d', 'd', 'd', 'i', 'd', 'd'], 1) ==
- [1, 0, 1, 2, 1, 1])
+ [1, 0, 1, 2, 1, 1])
assert (nxt.shortest_path_length(('d', 'd', 'd', 'i', 'd', 'd'), 1) ==
- [1, 0, 1, 2, 1, 1])
+ [1, 0, 1, 2, 1, 1])
assert pytest.raises(TypeError, nxt.shortest_path, [3., 1., 2.], 1)
def random_threshold_sequence(self):
assert len(nxt.random_threshold_sequence(10, 0.5)) == 10
assert (nxt.random_threshold_sequence(10, 0.5, seed=42) ==
- ['d', 'i', 'd', 'd', 'd', 'i', 'i', 'i', 'd', 'd'])
+ ['d', 'i', 'd', 'd', 'd', 'i', 'i', 'i', 'd', 'd'])
assert pytest.raises(ValueError, nxt.random_threshold_sequence, 10, 1.5)
def test_right_d_threshold_sequence(self):
@@ -142,19 +142,19 @@ class TestGeneratorThreshold():
wseq = nxt.creation_sequence_to_weights(nxt.uncompact([3, 1, 2, 3, 3, 2, 3]))
assert (wseq ==
- [s * 0.125 for s in [4, 4, 4, 3, 5, 5, 2, 2, 2, 6, 6, 6, 1, 1, 7, 7, 7]])
+ [s * 0.125 for s in [4, 4, 4, 3, 5, 5, 2, 2, 2, 6, 6, 6, 1, 1, 7, 7, 7]])
wseq = nxt.creation_sequence_to_weights([3, 1, 2, 3, 3, 2, 3])
assert (wseq ==
- [s * 0.125 for s in [4, 4, 4, 3, 5, 5, 2, 2, 2, 6, 6, 6, 1, 1, 7, 7, 7]])
+ [s * 0.125 for s in [4, 4, 4, 3, 5, 5, 2, 2, 2, 6, 6, 6, 1, 1, 7, 7, 7]])
wseq = nxt.creation_sequence_to_weights(list(enumerate('ddidiiidididi')))
assert (wseq ==
- [s * 0.1 for s in [5, 5, 4, 6, 3, 3, 3, 7, 2, 8, 1, 9, 0]])
+ [s * 0.1 for s in [5, 5, 4, 6, 3, 3, 3, 7, 2, 8, 1, 9, 0]])
wseq = nxt.creation_sequence_to_weights('ddidiiidididi')
assert (wseq ==
- [s * 0.1 for s in [5, 5, 4, 6, 3, 3, 3, 7, 2, 8, 1, 9, 0]])
+ [s * 0.1 for s in [5, 5, 4, 6, 3, 3, 3, 7, 2, 8, 1, 9, 0]])
wseq = nxt.creation_sequence_to_weights('ddidiiidididid')
ws = [s / float(12) for s in [6, 6, 5, 7, 4, 4, 4, 8, 3, 9, 2, 10, 1, 11]]
@@ -184,7 +184,7 @@ class TestGeneratorThreshold():
G = nxt.threshold_graph(cs)
assert nxt.density('ddiiddid') == nx.density(G)
assert (sorted(nxt.degree_sequence(cs)) ==
- sorted(d for n, d in G.degree()))
+ sorted(d for n, d in G.degree()))
ts = nxt.triangle_sequence(cs)
assert ts == list(nx.triangles(G).values())
@@ -236,6 +236,6 @@ class TestGeneratorThreshold():
cs = 'ddiiddid'
G = nxt.threshold_graph(cs)
assert pytest.raises(nx.exception.NetworkXError,
- nxt.threshold_graph, cs, create_using=nx.DiGraph())
+ nxt.threshold_graph, cs, create_using=nx.DiGraph())
MG = nxt.threshold_graph(cs, create_using=nx.MultiGraph())
assert sorted(MG.edges()) == sorted(G.edges())
diff --git a/networkx/algorithms/traversal/tests/test_bfs.py b/networkx/algorithms/traversal/tests/test_bfs.py
index 966ab4d2..de0e080a 100644
--- a/networkx/algorithms/traversal/tests/test_bfs.py
+++ b/networkx/algorithms/traversal/tests/test_bfs.py
@@ -12,11 +12,11 @@ class TestBFS:
def test_successor(self):
assert (dict(nx.bfs_successors(self.G, source=0)) ==
- {0: [1], 1: [2, 3], 2: [4]})
+ {0: [1], 1: [2, 3], 2: [4]})
def test_predecessor(self):
assert (dict(nx.bfs_predecessors(self.G, source=0)) ==
- {1: 0, 2: 1, 3: 1, 4: 2})
+ {1: 0, 2: 1, 3: 1, 4: 2})
def test_bfs_tree(self):
T = nx.bfs_tree(self.G, source=0)
@@ -59,18 +59,18 @@ class TestBreadthLimitedSearch:
def bfs_test_successor(self):
assert (dict(nx.bfs_successors(self.G, source=1, depth_limit=3)) ==
- {1: [0, 2], 2: [3, 7], 3: [4], 7: [8]})
+ {1: [0, 2], 2: [3, 7], 3: [4], 7: [8]})
result = {n: sorted(s) for n, s in nx.bfs_successors(self.D, source=7,
depth_limit=2)}
assert result == {8: [9], 2: [3], 7: [2, 8]}
def bfs_test_predecessor(self):
assert (dict(nx.bfs_predecessors(self.G, source=1,
- depth_limit=3)) ==
- {0: 1, 2: 1, 3: 2, 4: 3, 7: 2, 8: 7})
+ depth_limit=3)) ==
+ {0: 1, 2: 1, 3: 2, 4: 3, 7: 2, 8: 7})
assert (dict(nx.bfs_predecessors(self.D, source=7,
- depth_limit=2)) ==
- {2: 7, 3: 2, 8: 7, 9: 8})
+ depth_limit=2)) ==
+ {2: 7, 3: 2, 8: 7, 9: 8})
def bfs_test_tree(self):
T = nx.bfs_tree(self.G, source=3, depth_limit=1)
@@ -79,4 +79,4 @@ class TestBreadthLimitedSearch:
def bfs_test_edges(self):
edges = nx.bfs_edges(self.G, source=9, depth_limit=4)
assert list(edges) == [(9, 8), (9, 10), (8, 7),
- (7, 2), (2, 1), (2, 3)]
+ (7, 2), (2, 1), (2, 3)]
diff --git a/networkx/algorithms/traversal/tests/test_dfs.py b/networkx/algorithms/traversal/tests/test_dfs.py
index 75e25693..327a53f0 100644
--- a/networkx/algorithms/traversal/tests/test_dfs.py
+++ b/networkx/algorithms/traversal/tests/test_dfs.py
@@ -17,22 +17,22 @@ class TestDFS:
def test_preorder_nodes(self):
assert (list(nx.dfs_preorder_nodes(self.G, source=0)) ==
- [0, 1, 2, 4, 3])
+ [0, 1, 2, 4, 3])
assert list(nx.dfs_preorder_nodes(self.D)) == [0, 1, 2, 3]
def test_postorder_nodes(self):
assert (list(nx.dfs_postorder_nodes(self.G, source=0)) ==
- [3, 4, 2, 1, 0])
+ [3, 4, 2, 1, 0])
assert list(nx.dfs_postorder_nodes(self.D)) == [1, 0, 3, 2]
def test_successor(self):
assert (nx.dfs_successors(self.G, source=0) ==
- {0: [1], 1: [2], 2: [4], 4: [3]})
+ {0: [1], 1: [2], 2: [4], 4: [3]})
assert nx.dfs_successors(self.D) == {0: [1], 2: [3]}
def test_predecessor(self):
assert (nx.dfs_predecessors(self.G, source=0) ==
- {1: 0, 2: 1, 3: 4, 4: 2})
+ {1: 0, 2: 1, 3: 4, 4: 2})
assert nx.dfs_predecessors(self.D) == {1: 0, 3: 2}
def test_dfs_tree(self):
@@ -96,29 +96,29 @@ class TestDepthLimitedSearch:
def dls_test_preorder_nodes(self):
assert list(nx.dfs_preorder_nodes(self.G, source=0,
- depth_limit=2)) == [0, 1, 2]
+ depth_limit=2)) == [0, 1, 2]
assert list(nx.dfs_preorder_nodes(self.D, source=1,
- depth_limit=2)) == ([1, 0])
+ depth_limit=2)) == ([1, 0])
def dls_test_postorder_nodes(self):
assert list(nx.dfs_postorder_nodes(self.G,
- source=3, depth_limit=3)) == [1, 7, 2, 5, 4, 3]
+ source=3, depth_limit=3)) == [1, 7, 2, 5, 4, 3]
assert list(nx.dfs_postorder_nodes(self.D,
- source=2, depth_limit=2)) == ([3, 7, 2])
+ source=2, depth_limit=2)) == ([3, 7, 2])
def dls_test_successor(self):
result = nx.dfs_successors(self.G, source=4, depth_limit=3)
assert ({n: set(v) for n, v in result.items()} ==
- {2: {1, 7}, 3: {2}, 4: {3, 5}, 5: {6}})
+ {2: {1, 7}, 3: {2}, 4: {3, 5}, 5: {6}})
result = nx.dfs_successors(self.D, source=7, depth_limit=2)
assert ({n: set(v) for n, v in result.items()} ==
- {8: {9}, 2: {3}, 7: {8, 2}})
+ {8: {9}, 2: {3}, 7: {8, 2}})
def dls_test_predecessor(self):
assert (nx.dfs_predecessors(self.G, source=0, depth_limit=3) ==
- {1: 0, 2: 1, 3: 2, 7: 2})
+ {1: 0, 2: 1, 3: 2, 7: 2})
assert (nx.dfs_predecessors(self.D, source=2, depth_limit=3) ==
- {8: 7, 9: 8, 3: 2, 7: 2})
+ {8: 7, 9: 8, 3: 2, 7: 2})
def test_dls_tree(self):
T = nx.dfs_tree(self.G, source=3, depth_limit=1)
@@ -127,7 +127,7 @@ class TestDepthLimitedSearch:
def test_dls_edges(self):
edges = nx.dfs_edges(self.G, source=9, depth_limit=4)
assert list(edges) == [(9, 8), (8, 7),
- (7, 2), (2, 1), (2, 3), (9, 10)]
+ (7, 2), (2, 1), (2, 3), (9, 10)]
def test_dls_labeled_edges(self):
edges = list(nx.dfs_labeled_edges(self.G, source=5, depth_limit=1))
diff --git a/networkx/algorithms/tree/tests/test_branchings.py b/networkx/algorithms/tree/tests/test_branchings.py
index ba83a47d..1765cfe5 100644
--- a/networkx/algorithms/tree/tests/test_branchings.py
+++ b/networkx/algorithms/tree/tests/test_branchings.py
@@ -129,25 +129,25 @@ def assert_equal_branchings(G1, G2, attr='weight', default=1):
def test_optimal_branching1():
G = build_branching(optimal_arborescence_1)
assert recognition.is_arborescence(G), True
- assert branchings.branching_weight(G) == 131
+ assert branchings.branching_weight(G) == 131
def test_optimal_branching2a():
G = build_branching(optimal_branching_2a)
assert recognition.is_arborescence(G), True
- assert branchings.branching_weight(G) == 53
+ assert branchings.branching_weight(G) == 53
def test_optimal_branching2b():
G = build_branching(optimal_branching_2b)
assert recognition.is_arborescence(G), True
- assert branchings.branching_weight(G) == 53
+ assert branchings.branching_weight(G) == 53
def test_optimal_arborescence2():
G = build_branching(optimal_arborescence_2)
assert recognition.is_arborescence(G), True
- assert branchings.branching_weight(G) == 51
+ assert branchings.branching_weight(G) == 51
def test_greedy_suboptimal_branching1a():
diff --git a/networkx/classes/tests/test_digraph_historical.py b/networkx/classes/tests/test_digraph_historical.py
index b39ae3cc..340b1350 100644
--- a/networkx/classes/tests/test_digraph_historical.py
+++ b/networkx/classes/tests/test_digraph_historical.py
@@ -23,7 +23,7 @@ class TestDiGraphHistorical(HistoricalTests):
assert sorted(d for n, d in G.in_degree()) == [0, 0, 0, 0, 1, 2, 2]
assert (dict(G.in_degree()) ==
- {'A': 0, 'C': 2, 'B': 1, 'D': 2, 'G': 0, 'K': 0, 'J': 0})
+ {'A': 0, 'C': 2, 'B': 1, 'D': 2, 'G': 0, 'K': 0, 'J': 0})
def test_out_degree(self):
G = self.G()
@@ -31,9 +31,9 @@ class TestDiGraphHistorical(HistoricalTests):
G.add_edges_from([('A', 'B'), ('A', 'C'), ('B', 'D'),
('B', 'C'), ('C', 'D')])
assert (sorted([v for k, v in G.in_degree()]) ==
- [0, 0, 0, 0, 1, 2, 2])
+ [0, 0, 0, 0, 1, 2, 2])
assert (dict(G.out_degree()) ==
- {'A': 2, 'C': 1, 'B': 2, 'D': 0, 'G': 0, 'K': 0, 'J': 0})
+ {'A': 2, 'C': 1, 'B': 2, 'D': 0, 'G': 0, 'K': 0, 'J': 0})
def test_degree_digraph(self):
H = nx.DiGraph()
diff --git a/networkx/classes/tests/test_function.py b/networkx/classes/tests/test_function.py
index 79e76f75..8a0b7d65 100644
--- a/networkx/classes/tests/test_function.py
+++ b/networkx/classes/tests/test_function.py
@@ -27,7 +27,7 @@ class TestFunction(object):
assert_edges_equal(self.G.edges(nbunch=[0, 1, 3]),
list(nx.edges(self.G, nbunch=[0, 1, 3])))
assert (sorted(self.DG.edges(nbunch=[0, 1, 3])) ==
- sorted(nx.edges(self.DG, nbunch=[0, 1, 3])))
+ sorted(nx.edges(self.DG, nbunch=[0, 1, 3])))
def test_degree(self):
assert_edges_equal(self.G.degree(), list(nx.degree(self.G)))
@@ -35,11 +35,11 @@ class TestFunction(object):
assert_edges_equal(self.G.degree(nbunch=[0, 1]),
list(nx.degree(self.G, nbunch=[0, 1])))
assert (sorted(self.DG.degree(nbunch=[0, 1])) ==
- sorted(nx.degree(self.DG, nbunch=[0, 1])))
+ sorted(nx.degree(self.DG, nbunch=[0, 1])))
assert_edges_equal(self.G.degree(weight='weight'),
list(nx.degree(self.G, weight='weight')))
assert (sorted(self.DG.degree(weight='weight')) ==
- sorted(nx.degree(self.DG, weight='weight')))
+ sorted(nx.degree(self.DG, weight='weight')))
def test_neighbors(self):
assert list(self.G.neighbors(1)) == list(nx.neighbors(self.G, 1))
@@ -161,13 +161,13 @@ class TestFunction(object):
def test_subgraph(self):
assert (self.G.subgraph([0, 1, 2, 4]).adj ==
- nx.subgraph(self.G, [0, 1, 2, 4]).adj)
+ nx.subgraph(self.G, [0, 1, 2, 4]).adj)
assert (self.DG.subgraph([0, 1, 2, 4]).adj ==
- nx.subgraph(self.DG, [0, 1, 2, 4]).adj)
+ nx.subgraph(self.DG, [0, 1, 2, 4]).adj)
assert (self.G.subgraph([0, 1, 2, 4]).adj ==
- nx.induced_subgraph(self.G, [0, 1, 2, 4]).adj)
+ nx.induced_subgraph(self.G, [0, 1, 2, 4]).adj)
assert (self.DG.subgraph([0, 1, 2, 4]).adj ==
- nx.induced_subgraph(self.DG, [0, 1, 2, 4]).adj)
+ nx.induced_subgraph(self.DG, [0, 1, 2, 4]).adj)
# subgraph-subgraph chain is allowed in function interface
H = nx.induced_subgraph(self.G.subgraph([0, 1, 2, 4]), [0, 1, 4])
assert H._graph is not self.G
@@ -175,9 +175,9 @@ class TestFunction(object):
def test_edge_subgraph(self):
assert (self.G.edge_subgraph([(1, 2), (0, 3)]).adj ==
- nx.edge_subgraph(self.G, [(1, 2), (0, 3)]).adj)
+ nx.edge_subgraph(self.G, [(1, 2), (0, 3)]).adj)
assert (self.DG.edge_subgraph([(1, 2), (0, 3)]).adj ==
- nx.edge_subgraph(self.DG, [(1, 2), (0, 3)]).adj)
+ nx.edge_subgraph(self.DG, [(1, 2), (0, 3)]).adj)
def test_restricted_view(self):
H = nx.restricted_view(self.G, [0, 2, 5], [(1, 2), (3, 4)])
diff --git a/networkx/classes/tests/test_graph.py b/networkx/classes/tests/test_graph.py
index 93758c75..d1204f43 100644
--- a/networkx/classes/tests/test_graph.py
+++ b/networkx/classes/tests/test_graph.py
@@ -83,7 +83,7 @@ class BaseGraphTester(object):
G.add_edge(1, 2, weight=2)
G.add_edge(2, 3, weight=3)
assert (sorted(d for n, d in G.degree(weight='weight')) ==
- [2, 3, 5])
+ [2, 3, 5])
assert dict(G.degree(weight='weight')) == {1: 2, 2: 5, 3: 3}
assert G.degree(1, weight='weight') == 2
assert G.degree([1], weight='weight') == [(1, 2)]
@@ -165,7 +165,7 @@ class BaseAttrGraphTester(BaseGraphTester):
G.add_edge(1, 2, weight=2, other=3)
G.add_edge(2, 3, weight=3, other=4)
assert (sorted(d for n, d in G.degree(weight='weight')) ==
- [2, 3, 5])
+ [2, 3, 5])
assert dict(G.degree(weight='weight')) == {1: 2, 2: 5, 3: 3}
assert G.degree(1, weight='weight') == 2
assert_nodes_equal((G.degree([1], weight='weight')), [(1, 2)])
@@ -495,7 +495,7 @@ class TestGraph(BaseAttrGraphTester):
def test_adjacency(self):
G = self.K3
assert (dict(G.adjacency()) ==
- {0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}})
+ {0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}})
def test_getitem(self):
G = self.K3
@@ -578,7 +578,7 @@ class TestGraph(BaseAttrGraphTester):
G = self.Graph()
G.add_edges_from([(0, 1), (0, 2, {'weight': 3})])
assert G.adj == {0: {1: {}, 2: {'weight': 3}}, 1: {0: {}},
- 2: {0: {'weight': 3}}}
+ 2: {0: {'weight': 3}}}
G = self.Graph()
G.add_edges_from([(0, 1), (0, 2, {'weight': 3}),
(1, 2, {'data': 4})], data=2)
@@ -707,7 +707,7 @@ class TestEdgeSubgraph(object):
def test_correct_edges(self):
"""Tests that the subgraph has the correct edges."""
assert ([(0, 1, 'edge01'), (3, 4, 'edge34')] ==
- sorted(self.H.edges(data='name')))
+ sorted(self.H.edges(data='name')))
def test_add_node(self):
"""Tests that adding a node to the original graph does not
@@ -748,10 +748,10 @@ class TestEdgeSubgraph(object):
# Making a change to G should make a change in H and vice versa.
self.G.edges[0, 1]['name'] = 'foo'
assert (self.G.edges[0, 1]['name'] ==
- self.H.edges[0, 1]['name'])
+ self.H.edges[0, 1]['name'])
self.H.edges[3, 4]['name'] = 'bar'
assert (self.G.edges[3, 4]['name'] ==
- self.H.edges[3, 4]['name'])
+ self.H.edges[3, 4]['name'])
def test_graph_attr_dict(self):
"""Tests that the graph attribute dictionary of the two graphs
diff --git a/networkx/classes/tests/test_graphviews.py b/networkx/classes/tests/test_graphviews.py
index f6c00368..20422518 100644
--- a/networkx/classes/tests/test_graphviews.py
+++ b/networkx/classes/tests/test_graphviews.py
@@ -43,9 +43,9 @@ class TestReverseView(object):
M = MyGraph()
M.add_edge(1, 2)
RM = nx.reverse_view(M)
- print("RM class",RM.__class__)
+ print("RM class", RM.__class__)
RMC = RM.copy()
- print("RMC class",RMC.__class__)
+ print("RMC class", RMC.__class__)
print(RMC.edges)
assert RMC.has_edge(2, 1)
assert RMC.my_method() == "me"
@@ -172,8 +172,8 @@ class TestChainsOfViews(object):
cls.Rv = cls.DG.reverse()
cls.MRv = cls.MDG.reverse()
cls.graphs = [cls.G, cls.DG, cls.MG, cls.MDG,
- cls.Gv, cls.DGv, cls.MGv, cls.MDGv,
- cls.Rv, cls.MRv]
+ cls.Gv, cls.DGv, cls.MGv, cls.MDGv,
+ cls.Rv, cls.MRv]
for G in cls.graphs:
G.edges, G.nodes, G.degree
diff --git a/networkx/classes/tests/test_multidigraph.py b/networkx/classes/tests/test_multidigraph.py
index 11ceca77..45fd296e 100644
--- a/networkx/classes/tests/test_multidigraph.py
+++ b/networkx/classes/tests/test_multidigraph.py
@@ -25,16 +25,16 @@ class BaseMultiDiGraphTester(BaseMultiGraphTester):
def test_edges_multi(self):
G = self.K3
assert (sorted(G.edges()) ==
- [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
+ [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
assert sorted(G.edges(0)) == [(0, 1), (0, 2)]
G.add_edge(0, 1)
assert (sorted(G.edges()) ==
- [(0, 1), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
+ [(0, 1), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
def test_out_edges(self):
G = self.K3
assert (sorted(G.out_edges()) ==
- [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
+ [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
assert sorted(G.out_edges(0)) == [(0, 1), (0, 2)]
pytest.raises((KeyError, nx.NetworkXError), G.out_edges, -1)
assert sorted(G.out_edges(0, keys=True)) == [(0, 1, 0), (0, 2, 0)]
@@ -42,11 +42,11 @@ class BaseMultiDiGraphTester(BaseMultiGraphTester):
def test_out_edges_multi(self):
G = self.K3
assert (sorted(G.out_edges()) ==
- [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
+ [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
assert sorted(G.out_edges(0)) == [(0, 1), (0, 2)]
G.add_edge(0, 1, 2)
assert (sorted(G.out_edges()) ==
- [(0, 1), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
+ [(0, 1), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
def test_out_edges_data(self):
G = self.K3
@@ -54,48 +54,48 @@ class BaseMultiDiGraphTester(BaseMultiGraphTester):
G.remove_edge(0, 1)
G.add_edge(0, 1, data=1)
assert (sorted(G.edges(0, data=True)) ==
- [(0, 1, {'data': 1}), (0, 2, {})])
+ [(0, 1, {'data': 1}), (0, 2, {})])
assert (sorted(G.edges(0, data='data')) ==
- [(0, 1, 1), (0, 2, None)])
+ [(0, 1, 1), (0, 2, None)])
assert (sorted(G.edges(0, data='data', default=-1)) ==
- [(0, 1, 1), (0, 2, -1)])
+ [(0, 1, 1), (0, 2, -1)])
def test_in_edges(self):
G = self.K3
assert (sorted(G.in_edges()) ==
- [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
+ [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
assert sorted(G.in_edges(0)) == [(1, 0), (2, 0)]
pytest.raises((KeyError, nx.NetworkXError), G.in_edges, -1)
G.add_edge(0, 1, 2)
assert (sorted(G.in_edges()) ==
- [(0, 1), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
+ [(0, 1), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
assert sorted(G.in_edges(0, keys=True)) == [(1, 0, 0), (2, 0, 0)]
def test_in_edges_no_keys(self):
G = self.K3
assert (sorted(G.in_edges()) ==
- [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
+ [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
assert sorted(G.in_edges(0)) == [(1, 0), (2, 0)]
G.add_edge(0, 1, 2)
assert (sorted(G.in_edges()) ==
- [(0, 1), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
+ [(0, 1), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)])
assert (sorted(G.in_edges(data=True, keys=False)) ==
- [(0, 1, {}), (0, 1, {}), (0, 2, {}), (1, 0, {}),
- (1, 2, {}), (2, 0, {}), (2, 1, {})])
+ [(0, 1, {}), (0, 1, {}), (0, 2, {}), (1, 0, {}),
+ (1, 2, {}), (2, 0, {}), (2, 1, {})])
def test_in_edges_data(self):
G = self.K3
assert (sorted(G.in_edges(0, data=True)) ==
- [(1, 0, {}), (2, 0, {})])
+ [(1, 0, {}), (2, 0, {})])
G.remove_edge(1, 0)
G.add_edge(1, 0, data=1)
assert (sorted(G.in_edges(0, data=True)) ==
- [(1, 0, {'data': 1}), (2, 0, {})])
+ [(1, 0, {'data': 1}), (2, 0, {})])
assert (sorted(G.in_edges(0, data='data')) ==
- [(1, 0, 1), (2, 0, None)])
+ [(1, 0, 1), (2, 0, None)])
assert (sorted(G.in_edges(0, data='data', default=-1)) ==
- [(1, 0, 1), (2, 0, -1)])
+ [(1, 0, 1), (2, 0, -1)])
def is_shallow(self, H, G):
# graph
@@ -169,9 +169,9 @@ class BaseMultiDiGraphTester(BaseMultiGraphTester):
assert list(G.degree(iter([0]))) == [(0, 4)]
G.add_edge(0, 1, weight=0.3, other=1.2)
assert (sorted(G.degree(weight='weight')) ==
- [(0, 4.3), (1, 4.3), (2, 4)])
+ [(0, 4.3), (1, 4.3), (2, 4)])
assert (sorted(G.degree(weight='other')) ==
- [(0, 5.2), (1, 5.2), (2, 4)])
+ [(0, 5.2), (1, 5.2), (2, 4)])
def test_in_degree(self):
G = self.K3
@@ -263,13 +263,13 @@ class TestMultiDiGraph(BaseMultiDiGraphTester, TestMultiGraph):
G.add_edges_from([(0, 1), (0, 1, {'weight': 3})], weight=2)
assert G._succ == {0: {1: {0: {},
- 1: {'weight': 3},
- 2: {'weight': 2},
- 3: {'weight': 3}}},
- 1: {}}
+ 1: {'weight': 3},
+ 2: {'weight': 2},
+ 3: {'weight': 3}}},
+ 1: {}}
assert G._pred == {0: {}, 1: {0: {0: {}, 1: {'weight': 3},
- 2: {'weight': 2},
- 3: {'weight': 3}}}}
+ 2: {'weight': 2},
+ 3: {'weight': 3}}}}
G = self.Graph()
edges = [(0, 1, {'weight': 3}), (0, 1, (('weight', 2),)),
@@ -290,11 +290,11 @@ class TestMultiDiGraph(BaseMultiDiGraphTester, TestMultiGraph):
G = self.K3
G.remove_edge(0, 1)
assert G._succ == {0: {2: {0: {}}},
- 1: {0: {0: {}}, 2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}}
+ 1: {0: {0: {}}, 2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}}
assert G._pred == {0: {1: {0: {}}, 2: {0: {}}},
- 1: {2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}}
+ 1: {2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}}
pytest.raises((KeyError, nx.NetworkXError), G.remove_edge, -1, 0)
pytest.raises((KeyError, nx.NetworkXError), G.remove_edge, 0, 2,
key=1)
@@ -304,34 +304,34 @@ class TestMultiDiGraph(BaseMultiDiGraphTester, TestMultiGraph):
G.add_edge(0, 1, key='parallel edge')
G.remove_edge(0, 1, key='parallel edge')
assert G._adj == {0: {1: {0: {}}, 2: {0: {}}},
- 1: {0: {0: {}}, 2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}}
+ 1: {0: {0: {}}, 2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}}
assert G._succ == {0: {1: {0: {}}, 2: {0: {}}},
- 1: {0: {0: {}}, 2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}}
+ 1: {0: {0: {}}, 2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}}
assert G._pred == {0: {1: {0: {}}, 2: {0: {}}},
- 1: {0: {0: {}}, 2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}}
+ 1: {0: {0: {}}, 2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}}
G.remove_edge(0, 1)
assert G._succ == {0: {2: {0: {}}},
- 1: {0: {0: {}}, 2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}}
+ 1: {0: {0: {}}, 2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}}
assert G._pred == {0: {1: {0: {}}, 2: {0: {}}},
- 1: {2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}}
+ 1: {2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}}
pytest.raises((KeyError, nx.NetworkXError), G.remove_edge, -1, 0)
def test_remove_edges_from(self):
G = self.K3
G.remove_edges_from([(0, 1)])
assert G._succ == {0: {2: {0: {}}},
- 1: {0: {0: {}}, 2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}}
+ 1: {0: {0: {}}, 2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}}
assert G._pred == {0: {1: {0: {}}, 2: {0: {}}},
- 1: {2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}}
+ 1: {2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}}
G.remove_edges_from([(0, 0)]) # silent fail
diff --git a/networkx/classes/tests/test_multigraph.py b/networkx/classes/tests/test_multigraph.py
index 13b4f2e0..c52251d7 100644
--- a/networkx/classes/tests/test_multigraph.py
+++ b/networkx/classes/tests/test_multigraph.py
@@ -27,9 +27,9 @@ class BaseMultiGraphTester(BaseAttrGraphTester):
def test_adjacency(self):
G = self.K3
assert (dict(G.adjacency()) ==
- {0: {1: {0: {}}, 2: {0: {}}},
- 1: {0: {0: {}}, 2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}})
+ {0: {1: {0: {}}, 2: {0: {}}},
+ 1: {0: {0: {}}, 2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}})
def deepcopy_edge_attr(self, H, G):
assert G[1][2][0]['foo'] == H[1][2][0]['foo']
@@ -204,12 +204,12 @@ class TestMultiGraph(BaseMultiGraphTester, TestGraph):
G = self.Graph()
G.add_edges_from([(0, 1), (0, 1, {'weight': 3})])
assert G.adj == {0: {1: {0: {}, 1: {'weight': 3}}},
- 1: {0: {0: {}, 1: {'weight': 3}}}}
+ 1: {0: {0: {}, 1: {'weight': 3}}}}
G.add_edges_from([(0, 1), (0, 1, {'weight': 3})], weight=2)
assert G.adj == {0: {1: {0: {}, 1: {'weight': 3},
- 2: {'weight': 2}, 3: {'weight': 3}}},
- 1: {0: {0: {}, 1: {'weight': 3},
- 2: {'weight': 2}, 3: {'weight': 3}}}}
+ 2: {'weight': 2}, 3: {'weight': 3}}},
+ 1: {0: {0: {}, 1: {'weight': 3},
+ 2: {'weight': 2}, 3: {'weight': 3}}}}
G = self.Graph()
edges = [(0, 1, {'weight': 3}), (0, 1, (('weight', 2),)),
(0, 1, 5), (0, 1, 's')]
@@ -231,9 +231,9 @@ class TestMultiGraph(BaseMultiGraphTester, TestGraph):
G = self.K3
G.remove_edge(0, 1)
assert G.adj == {0: {2: {0: {}}},
- 1: {2: {0: {}}},
- 2: {0: {0: {}},
- 1: {0: {}}}}
+ 1: {2: {0: {}}},
+ 2: {0: {0: {}},
+ 1: {0: {}}}}
with pytest.raises(nx.NetworkXError):
G.remove_edge(-1, 0)
@@ -265,8 +265,8 @@ class TestMultiGraph(BaseMultiGraphTester, TestGraph):
G.add_edge(0, 1, key='parallel edge')
G.remove_edge(0, 1, key='parallel edge')
assert G.adj == {0: {1: {0: {}}, 2: {0: {}}},
- 1: {0: {0: {}}, 2: {0: {}}},
- 2: {0: {0: {}}, 1: {0: {}}}}
+ 1: {0: {0: {}}, 2: {0: {}}},
+ 2: {0: {0: {}}, 1: {0: {}}}}
G.remove_edge(0, 1)
kd = {0: {}}
assert G.adj == {0: {2: kd}, 1: {2: kd}, 2: {0: kd, 1: kd}}
@@ -302,7 +302,7 @@ class TestEdgeSubgraph(object):
def test_correct_edges(self):
"""Tests that the subgraph has the correct edges."""
assert ([(0, 1, 0, 'edge010'), (3, 4, 1, 'edge341')] ==
- sorted(self.H.edges(keys=True, data='name')))
+ sorted(self.H.edges(keys=True, data='name')))
def test_add_node(self):
"""Tests that adding a node to the original graph does not
@@ -343,10 +343,10 @@ class TestEdgeSubgraph(object):
# Making a change to G should make a change in H and vice versa.
self.G._adj[0][1][0]['name'] = 'foo'
assert (self.G._adj[0][1][0]['name'] ==
- self.H._adj[0][1][0]['name'])
+ self.H._adj[0][1][0]['name'])
self.H._adj[3][4][1]['name'] = 'bar'
assert (self.G._adj[3][4][1]['name'] ==
- self.H._adj[3][4][1]['name'])
+ self.H._adj[3][4][1]['name'])
def test_graph_attr_dict(self):
"""Tests that the graph attribute dictionary of the two graphs
diff --git a/networkx/classes/tests/test_subgraphviews.py b/networkx/classes/tests/test_subgraphviews.py
index dd93a494..f82823d3 100644
--- a/networkx/classes/tests/test_subgraphviews.py
+++ b/networkx/classes/tests/test_subgraphviews.py
@@ -291,7 +291,7 @@ class TestEdgeSubGraph(object):
def test_correct_edges(self):
"""Tests that the subgraph has the correct edges."""
assert ([(0, 1, 'edge01'), (3, 4, 'edge34')] ==
- sorted(self.H.edges(data='name')))
+ sorted(self.H.edges(data='name')))
def test_add_node(self):
"""Tests that adding a node to the original graph does not
@@ -334,10 +334,10 @@ class TestEdgeSubGraph(object):
# Making a change to G should make a change in H and vice versa.
self.G.edges[0, 1]['name'] = 'foo'
assert (self.G.edges[0, 1]['name'] ==
- self.H.edges[0, 1]['name'])
+ self.H.edges[0, 1]['name'])
self.H.edges[3, 4]['name'] = 'bar'
assert (self.G.edges[3, 4]['name'] ==
- self.H.edges[3, 4]['name'])
+ self.H.edges[3, 4]['name'])
def test_graph_attr_dict(self):
"""Tests that the graph attribute dictionary of the two graphs
diff --git a/networkx/convert_matrix.py b/networkx/convert_matrix.py
index beb20325..474d53db 100644
--- a/networkx/convert_matrix.py
+++ b/networkx/convert_matrix.py
@@ -124,8 +124,8 @@ def to_pandas_adjacency(G, nodelist=None, dtype=None, order=None,
"""
import pandas as pd
M = to_numpy_array(G, nodelist=nodelist, dtype=dtype, order=order,
- multigraph_weight=multigraph_weight, weight=weight,
- nonedge=nonedge)
+ multigraph_weight=multigraph_weight, weight=weight,
+ nonedge=nonedge)
if nodelist is None:
nodelist = list(G)
return pd.DataFrame(data=M, index=nodelist, columns=nodelist)
diff --git a/networkx/drawing/tests/test_layout.py b/networkx/drawing/tests/test_layout.py
index d392d83f..be4a9738 100644
--- a/networkx/drawing/tests/test_layout.py
+++ b/networkx/drawing/tests/test_layout.py
@@ -8,6 +8,7 @@ import pytest
import networkx as nx
from networkx.testing import almost_equal
+
class TestLayout(object):
@classmethod
diff --git a/networkx/drawing/tests/test_pydot.py b/networkx/drawing/tests/test_pydot.py
index cf912bf9..8ddfca97 100644
--- a/networkx/drawing/tests/test_pydot.py
+++ b/networkx/drawing/tests/test_pydot.py
@@ -14,6 +14,7 @@ from networkx.testing import assert_graphs_equal
import pytest
pydot = pytest.importorskip('pydot')
+
class TestPydot(object):
def pydot_checks(self, G, prog):
'''
diff --git a/networkx/drawing/tests/test_pylab.py b/networkx/drawing/tests/test_pylab.py
index bff1c4a0..2ecd268d 100644
--- a/networkx/drawing/tests/test_pylab.py
+++ b/networkx/drawing/tests/test_pylab.py
@@ -96,11 +96,11 @@ class TestPylab(object):
edge_color=[(0.4, 1.0, 0.0)])
# with rgba tuple and 4 edges - is interpretted with cmap
nx.draw_networkx_edges(G, pos, edgelist=[(9, 10), (10, 11),
- (10, 12), (10, 13)],
+ (10, 12), (10, 13)],
edge_color=(0.0, 1.0, 1.0, 0.5))
# with rgba tuple in list
nx.draw_networkx_edges(G, pos, edgelist=[(9, 10), (10, 11),
- (10, 12), (10, 13)],
+ (10, 12), (10, 13)],
edge_color=[(0.0, 1.0, 1.0, 0.5)])
# with color string and global alpha
nx.draw_networkx_edges(G, pos, edgelist=[(11, 12), (11, 13)],
diff --git a/networkx/generators/tests/test_classic.py b/networkx/generators/tests/test_classic.py
index a605cb6a..284814fa 100644
--- a/networkx/generators/tests/test_classic.py
+++ b/networkx/generators/tests/test_classic.py
@@ -138,7 +138,7 @@ class TestGeneratorClassic():
assert_edges_equal(mb.edges(), b.edges())
def test_binomial_tree(self):
- for n in range(0,4):
+ for n in range(0, 4):
b = nx.binomial_tree(n)
assert nx.number_of_nodes(b) == 2**n
assert nx.number_of_edges(b) == (2**n - 1)
@@ -350,7 +350,7 @@ class TestGeneratorClassic():
p = nx.path_graph(10)
assert nx.is_connected(p)
assert (sorted(d for n, d in p.degree()) ==
- [1, 1, 2, 2, 2, 2, 2, 2, 2, 2])
+ [1, 1, 2, 2, 2, 2, 2, 2, 2, 2])
assert p.order() - 1 == p.size()
dp = nx.path_graph(3, create_using=nx.DiGraph)
@@ -377,7 +377,7 @@ class TestGeneratorClassic():
s = star_graph(10)
assert (sorted(d for n, d in s.degree()) ==
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10])
+ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10])
pytest.raises(nx.NetworkXError,
star_graph, 10, create_using=nx.DiGraph)
@@ -395,7 +395,7 @@ class TestGeneratorClassic():
def test_turan_graph(self):
assert nx.number_of_edges(nx.turan_graph(13, 4)) == 63
assert is_isomorphic(nx.turan_graph(13, 4),
- nx.complete_multipartite_graph(3, 4, 3, 3))
+ nx.complete_multipartite_graph(3, 4, 3, 3))
def test_wheel_graph(self):
for n, G in [(0, nx.null_graph()), (1, nx.empty_graph(1)),
@@ -406,7 +406,7 @@ class TestGeneratorClassic():
g = nx.wheel_graph(10)
assert (sorted(d for n, d in g.degree()) ==
- [3, 3, 3, 3, 3, 3, 3, 3, 3, 9])
+ [3, 3, 3, 3, 3, 3, 3, 3, 3, 9])
pytest.raises(nx.NetworkXError,
nx.wheel_graph, 10, create_using=nx.DiGraph)
diff --git a/networkx/generators/tests/test_cographs.py b/networkx/generators/tests/test_cographs.py
index 6e0ce7ca..320aa56d 100644
--- a/networkx/generators/tests/test_cographs.py
+++ b/networkx/generators/tests/test_cographs.py
@@ -20,7 +20,7 @@ def test_random_cograph():
assert len(G) == 2 ** n
- #Every connected subgraph of G has diameter <= 2
+ # Every connected subgraph of G has diameter <= 2
if nx.is_connected(G):
assert nx.diameter(G) <= 2
else:
diff --git a/networkx/generators/tests/test_community.py b/networkx/generators/tests/test_community.py
index b62bcc6d..0b66231f 100644
--- a/networkx/generators/tests/test_community.py
+++ b/networkx/generators/tests/test_community.py
@@ -30,7 +30,7 @@ def test_random_partition_graph():
G = nx.random_partition_graph([1, 2, 3, 4, 5], 0.5, 0.1)
C = G.graph['partition']
assert C == [set([0]), set([1, 2]), set([3, 4, 5]),
- set([6, 7, 8, 9]), set([10, 11, 12, 13, 14])]
+ set([6, 7, 8, 9]), set([10, 11, 12, 13, 14])]
assert len(G) == 15
rpg = nx.random_partition_graph
diff --git a/networkx/generators/tests/test_degree_seq.py b/networkx/generators/tests/test_degree_seq.py
index 70062775..76e7f69a 100644
--- a/networkx/generators/tests/test_degree_seq.py
+++ b/networkx/generators/tests/test_degree_seq.py
@@ -31,10 +31,10 @@ class TestConfigurationModel(object):
deg_seq = [5, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1]
G = nx.configuration_model(deg_seq, seed=12345678)
assert (sorted((d for n, d in G.degree()), reverse=True) ==
- [5, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1])
+ [5, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1])
assert (sorted((d for n, d in G.degree(range(len(deg_seq)))),
- reverse=True) ==
- [5, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1])
+ reverse=True) ==
+ [5, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1])
def test_random_seed(self):
"""Tests that each call with the same random seed generates the
diff --git a/networkx/generators/tests/test_lattice.py b/networkx/generators/tests/test_lattice.py
index dfa2e543..d164bccf 100644
--- a/networkx/generators/tests/test_lattice.py
+++ b/networkx/generators/tests/test_lattice.py
@@ -82,7 +82,7 @@ class TestGridGraph:
g = nx.grid_graph(dim)
assert len(g) == n * m
assert nx.degree_histogram(g) == [0, 0, 4, 2 * (n + m) - 8,
- (n - 2) * (m - 2)]
+ (n - 2) * (m - 2)]
for n, m in [(1, 5), (5, 1)]:
dim = [n, m]
diff --git a/networkx/generators/tests/test_line.py b/networkx/generators/tests/test_line.py
index 23fe0398..ea162bf4 100644
--- a/networkx/generators/tests/test_line.py
+++ b/networkx/generators/tests/test_line.py
@@ -134,7 +134,7 @@ class TestGeneratorInverseLine():
# there are two alternative inverse line graphs for this case
# so long as we get one of them the test should pass
assert (nx.is_isomorphic(H, G) or
- nx.is_isomorphic(H, alternative_solution))
+ nx.is_isomorphic(H, alternative_solution))
def test_cycle(self):
G = nx.cycle_graph(5)
@@ -180,7 +180,7 @@ class TestGeneratorInverseLine():
# K_5 minus an edge
K5me = nx.complete_graph(5)
- K5me.remove_edge(0,1)
+ K5me.remove_edge(0, 1)
pytest.raises(nx.NetworkXError, nx.inverse_line_graph, K5me)
def test_wrong_graph_type(self):
diff --git a/networkx/generators/tests/test_random_graphs.py b/networkx/generators/tests/test_random_graphs.py
index a81bd00d..57eedf14 100644
--- a/networkx/generators/tests/test_random_graphs.py
+++ b/networkx/generators/tests/test_random_graphs.py
@@ -248,16 +248,16 @@ class TestGeneratorsRandom(object):
assert sum(1 for _ in G.edges()) == 0
def test_watts_strogatz_big_k(self):
- #Test to make sure than n <= k
+ # Test to make sure than n <= k
pytest.raises(NetworkXError, watts_strogatz_graph, 10, 11, 0.25)
pytest.raises(NetworkXError, newman_watts_strogatz_graph, 10, 11, 0.25)
-
+
# could create an infinite loop, now doesn't
# infinite loop used to occur when a node has degree n-1 and needs to rewire
watts_strogatz_graph(10, 9, 0.25, seed=0)
newman_watts_strogatz_graph(10, 9, 0.5, seed=0)
- #Test k==n scenario
+ # Test k==n scenario
watts_strogatz_graph(10, 10, 0.25, seed=0)
newman_watts_strogatz_graph(10, 10, 0.25, seed=0)
diff --git a/networkx/generators/tests/test_small.py b/networkx/generators/tests/test_small.py
index 43c22aa5..2cba086b 100644
--- a/networkx/generators/tests/test_small.py
+++ b/networkx/generators/tests/test_small.py
@@ -118,7 +118,7 @@ class TestGeneratorsSmall():
assert G.number_of_nodes() == 12
assert G.number_of_edges() == 30
assert (list(d for n, d in G.degree()) ==
- [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])
+ [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])
assert nx.diameter(G) == 3
assert nx.radius(G) == 3
@@ -126,7 +126,7 @@ class TestGeneratorsSmall():
assert G.number_of_nodes() == 10
assert G.number_of_edges() == 18
assert (sorted(d for n, d in G.degree()) ==
- [1, 2, 3, 3, 3, 4, 4, 5, 5, 6])
+ [1, 2, 3, 3, 3, 4, 4, 5, 5, 6])
G = nx.moebius_kantor_graph()
assert G.number_of_nodes() == 16
diff --git a/networkx/generators/tests/test_stochastic.py b/networkx/generators/tests/test_stochastic.py
index 1cedd0a5..bc217f31 100644
--- a/networkx/generators/tests/test_stochastic.py
+++ b/networkx/generators/tests/test_stochastic.py
@@ -23,7 +23,7 @@ class TestStochasticGraph(object):
S = nx.stochastic_graph(G)
assert nx.is_isomorphic(G, S)
assert (sorted(S.edges(data=True)) ==
- [(0, 1, {'weight': 0.5}), (0, 2, {'weight': 0.5})])
+ [(0, 1, {'weight': 0.5}), (0, 2, {'weight': 0.5})])
def test_in_place(self):
"""Tests for an in-place reweighting of the edges of the graph.
@@ -34,7 +34,7 @@ class TestStochasticGraph(object):
G.add_edge(0, 2, weight=1)
nx.stochastic_graph(G, copy=False)
assert (sorted(G.edges(data=True)) ==
- [(0, 1, {'weight': 0.5}), (0, 2, {'weight': 0.5})])
+ [(0, 1, {'weight': 0.5}), (0, 2, {'weight': 0.5})])
def test_arbitrary_weights(self):
G = nx.DiGraph()
@@ -42,7 +42,7 @@ class TestStochasticGraph(object):
G.add_edge(0, 2, weight=1)
S = nx.stochastic_graph(G)
assert (sorted(S.edges(data=True)) ==
- [(0, 1, {'weight': 0.5}), (0, 2, {'weight': 0.5})])
+ [(0, 1, {'weight': 0.5}), (0, 2, {'weight': 0.5})])
def test_multidigraph(self):
G = nx.MultiDiGraph()
@@ -50,7 +50,7 @@ class TestStochasticGraph(object):
S = nx.stochastic_graph(G)
d = dict(weight=0.25)
assert (sorted(S.edges(data=True)) ==
- [(0, 1, d), (0, 1, d), (0, 2, d), (0, 2, d)])
+ [(0, 1, d), (0, 1, d), (0, 2, d), (0, 2, d)])
def test_graph_disallowed(self):
with pytest.raises(nx.NetworkXNotImplemented):
diff --git a/networkx/linalg/tests/test_algebraic_connectivity.py b/networkx/linalg/tests/test_algebraic_connectivity.py
index d406d658..f4a96a90 100644
--- a/networkx/linalg/tests/test_algebraic_connectivity.py
+++ b/networkx/linalg/tests/test_algebraic_connectivity.py
@@ -7,7 +7,6 @@ scipy = pytest.importorskip('scipy')
scipy.sparse = pytest.importorskip('scipy.sparse')
-
import networkx as nx
from networkx.testing import almost_equal
diff --git a/networkx/linalg/tests/test_bethehessian.py b/networkx/linalg/tests/test_bethehessian.py
index a0f17eb9..4b419aac 100644
--- a/networkx/linalg/tests/test_bethehessian.py
+++ b/networkx/linalg/tests/test_bethehessian.py
@@ -18,17 +18,17 @@ class TestBetheHessian(object):
def test_bethe_hessian(self):
"Bethe Hessian matrix"
H = numpy.array([[ 4, -2, 0],
- [-2, 5, -2],
- [ 0, -2, 4]])
+ [-2, 5, -2],
+ [ 0, -2, 4]])
permutation = [2, 0, 1]
# Bethe Hessian gives expected form
npt.assert_equal(nx.bethe_hessian_matrix(self.P, r=2).todense(), H)
# nodelist is correctly implemented
npt.assert_equal(nx.bethe_hessian_matrix(self.P, r=2, nodelist=permutation).todense(),
- H[numpy.ix_(permutation, permutation)])
+ H[numpy.ix_(permutation, permutation)])
# Equal to Laplacian matrix when r=1
npt.assert_equal(nx.bethe_hessian_matrix(self.G, r=1).todense(),
- nx.laplacian_matrix(self.G).todense())
+ nx.laplacian_matrix(self.G).todense())
# Correct default for the regularizer r
npt.assert_equal(nx.bethe_hessian_matrix(self.G).todense(),
- nx.bethe_hessian_matrix(self.G, r=1.25).todense())
+ nx.bethe_hessian_matrix(self.G, r=1.25).todense())
diff --git a/networkx/linalg/tests/test_graphmatrix.py b/networkx/linalg/tests/test_graphmatrix.py
index d1e06767..cafe1869 100644
--- a/networkx/linalg/tests/test_graphmatrix.py
+++ b/networkx/linalg/tests/test_graphmatrix.py
@@ -14,36 +14,36 @@ class TestGraphMatrix(object):
deg = [3, 2, 2, 1, 0]
cls.G = havel_hakimi_graph(deg)
cls.OI = numpy.array([[-1, -1, -1, 0],
- [1, 0, 0, -1],
- [0, 1, 0, 1],
- [0, 0, 1, 0],
- [0, 0, 0, 0]])
+ [1, 0, 0, -1],
+ [0, 1, 0, 1],
+ [0, 0, 1, 0],
+ [0, 0, 0, 0]])
cls.A = numpy.array([[0, 1, 1, 1, 0],
- [1, 0, 1, 0, 0],
- [1, 1, 0, 0, 0],
- [1, 0, 0, 0, 0],
- [0, 0, 0, 0, 0]])
+ [1, 0, 1, 0, 0],
+ [1, 1, 0, 0, 0],
+ [1, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0]])
cls.WG = havel_hakimi_graph(deg)
cls.WG.add_edges_from((u, v, {'weight': 0.5, 'other': 0.3})
- for (u, v) in cls.G.edges())
+ for (u, v) in cls.G.edges())
cls.WA = numpy.array([[0, 0.5, 0.5, 0.5, 0],
- [0.5, 0, 0.5, 0, 0],
- [0.5, 0.5, 0, 0, 0],
- [0.5, 0, 0, 0, 0],
- [0, 0, 0, 0, 0]])
+ [0.5, 0, 0.5, 0, 0],
+ [0.5, 0.5, 0, 0, 0],
+ [0.5, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0]])
cls.MG = nx.MultiGraph(cls.G)
cls.MG2 = cls.MG.copy()
cls.MG2.add_edge(0, 1)
cls.MG2A = numpy.array([[0, 2, 1, 1, 0],
- [2, 0, 1, 0, 0],
- [1, 1, 0, 0, 0],
- [1, 0, 0, 0, 0],
- [0, 0, 0, 0, 0]])
+ [2, 0, 1, 0, 0],
+ [1, 1, 0, 0, 0],
+ [1, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0]])
cls.MGOI = numpy.array([[-1, -1, -1, -1, 0],
- [1, 1, 0, 0, -1],
- [0, 0, 1, 0, 1],
- [0, 0, 0, 1, 0],
- [0, 0, 0, 0, 0]])
+ [1, 1, 0, 0, -1],
+ [0, 0, 1, 0, 1],
+ [0, 0, 0, 1, 0],
+ [0, 0, 0, 0, 0]])
cls.no_edges_G = nx.Graph([(1, 2), (3, 2, {'weight': 8})])
cls.no_edges_A = numpy.array([[0, 0], [0, 0]])
diff --git a/networkx/linalg/tests/test_laplacian.py b/networkx/linalg/tests/test_laplacian.py
index 003c3b36..0b631182 100644
--- a/networkx/linalg/tests/test_laplacian.py
+++ b/networkx/linalg/tests/test_laplacian.py
@@ -14,7 +14,7 @@ class TestLaplacian(object):
deg = [3, 2, 2, 1, 0]
cls.G = havel_hakimi_graph(deg)
cls.WG = nx.Graph((u, v, {'weight': 0.5, 'other': 0.3})
- for (u, v) in cls.G.edges())
+ for (u, v) in cls.G.edges())
cls.WG.add_node(4)
cls.MG = nx.MultiGraph(cls.G)
@@ -35,7 +35,7 @@ class TestLaplacian(object):
npt.assert_equal(nx.laplacian_matrix(self.G).todense(), NL)
npt.assert_equal(nx.laplacian_matrix(self.MG).todense(), NL)
npt.assert_equal(nx.laplacian_matrix(self.G, nodelist=[0, 1]).todense(),
- numpy.array([[1, -1], [-1, 1]]))
+ numpy.array([[1, -1], [-1, 1]]))
npt.assert_equal(nx.laplacian_matrix(self.WG).todense(), WL)
npt.assert_equal(nx.laplacian_matrix(self.WG, weight=None).todense(), NL)
npt.assert_equal(nx.laplacian_matrix(self.WG, weight='other').todense(), OL)
@@ -54,15 +54,15 @@ class TestLaplacian(object):
[0., 0., 0., 0., 0.]])
npt.assert_almost_equal(nx.normalized_laplacian_matrix(self.G).todense(),
- GL, decimal=3)
+ GL, decimal=3)
npt.assert_almost_equal(nx.normalized_laplacian_matrix(self.MG).todense(),
- GL, decimal=3)
+ GL, decimal=3)
npt.assert_almost_equal(nx.normalized_laplacian_matrix(self.WG).todense(),
- GL, decimal=3)
+ GL, decimal=3)
npt.assert_almost_equal(nx.normalized_laplacian_matrix(self.WG, weight='other').todense(),
- GL, decimal=3)
+ GL, decimal=3)
npt.assert_almost_equal(nx.normalized_laplacian_matrix(self.Gsl).todense(),
- Lsl, decimal=3)
+ Lsl, decimal=3)
def test_directed_laplacian(self):
"Directed Laplacian"
diff --git a/networkx/linalg/tests/test_modularity.py b/networkx/linalg/tests/test_modularity.py
index 9adbe5c2..edddff29 100644
--- a/networkx/linalg/tests/test_modularity.py
+++ b/networkx/linalg/tests/test_modularity.py
@@ -30,7 +30,7 @@ class TestModularity(object):
permutation = [4, 0, 1, 2, 3]
npt.assert_equal(nx.modularity_matrix(self.G), B)
npt.assert_equal(nx.modularity_matrix(self.G, nodelist=permutation),
- B[numpy.ix_(permutation, permutation)])
+ B[numpy.ix_(permutation, permutation)])
def test_modularity_weight(self):
"Modularity matrix with weights"
@@ -61,5 +61,5 @@ class TestModularity(object):
mm = nx.directed_modularity_matrix(self.DG, nodelist=sorted(self.DG))
npt.assert_equal(mm, B)
npt.assert_equal(nx.directed_modularity_matrix(self.DG,
- nodelist=node_permutation),
- B[numpy.ix_(idx_permutation, idx_permutation)])
+ nodelist=node_permutation),
+ B[numpy.ix_(idx_permutation, idx_permutation)])
diff --git a/networkx/linalg/tests/test_spectrum.py b/networkx/linalg/tests/test_spectrum.py
index 63fdcf00..fb2b8bb2 100644
--- a/networkx/linalg/tests/test_spectrum.py
+++ b/networkx/linalg/tests/test_spectrum.py
@@ -15,7 +15,7 @@ class TestSpectrum(object):
cls.G = havel_hakimi_graph(deg)
cls.P = nx.path_graph(3)
cls.WG = nx.Graph((u, v, {'weight': 0.5, 'other': 0.3})
- for (u, v) in cls.G.edges())
+ for (u, v) in cls.G.edges())
cls.WG.add_node(4)
cls.DG = nx.DiGraph()
nx.add_path(cls.DG, [0, 1, 2])
@@ -44,7 +44,6 @@ class TestSpectrum(object):
e = sorted(nx.normalized_laplacian_spectrum(self.WG, weight='other'))
npt.assert_almost_equal(e, evals)
-
def test_adjacency_spectrum(self):
"Adjacency eigenvalues"
evals = numpy.array([-numpy.sqrt(2), 0, numpy.sqrt(2)])
diff --git a/networkx/readwrite/nx_shp.py b/networkx/readwrite/nx_shp.py
index d6089264..aa05d8b5 100644
--- a/networkx/readwrite/nx_shp.py
+++ b/networkx/readwrite/nx_shp.py
@@ -275,7 +275,6 @@ def write_shp(G, outdir):
newfield = ogr.FieldDefn(key, fields[key])
layer.CreateField(newfield)
-
drv = ogr.GetDriverByName("ESRI Shapefile")
shpdir = drv.CreateDataSource(outdir)
# delete pre-existing output first otherwise ogr chokes
diff --git a/networkx/readwrite/tests/test_edgelist.py b/networkx/readwrite/tests/test_edgelist.py
index a0d812c4..371216b0 100644
--- a/networkx/readwrite/tests/test_edgelist.py
+++ b/networkx/readwrite/tests/test_edgelist.py
@@ -81,9 +81,8 @@ class TestEdgelist:
bytesIO = io.BytesIO(s)
G = nx.read_edgelist(bytesIO, nodetype=int, data=True)
assert_edges_equal(G.edges(data=True),
- [(1, 2, {'weight': 2.0}), (2, 3, {'weight': 3.0})])
-
-
+ [(1, 2, {'weight': 2.0}), (2, 3, {'weight': 3.0})])
+
s = """\
# comment line
1 2 {'weight':2.0}
@@ -97,7 +96,7 @@ class TestEdgelist:
StringIO = io.StringIO(s)
G = nx.read_edgelist(StringIO, nodetype=int, data=True)
assert_edges_equal(G.edges(data=True),
- [(1, 2, {'weight': 2.0}), (2, 3, {'weight': 3.0})])
+ [(1, 2, {'weight': 2.0}), (2, 3, {'weight': 3.0})])
def test_write_edgelist_1(self):
fh = io.BytesIO()
diff --git a/networkx/readwrite/tests/test_gexf.py b/networkx/readwrite/tests/test_gexf.py
index 0c5ee620..ea067a38 100644
--- a/networkx/readwrite/tests/test_gexf.py
+++ b/networkx/readwrite/tests/test_gexf.py
@@ -92,21 +92,21 @@ org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gexf.net/\
cls.attribute_graph = nx.DiGraph()
cls.attribute_graph.graph['node_default'] = {'frog': True}
cls.attribute_graph.add_node('0',
- label='Gephi',
- url='https://gephi.org',
- indegree=1, frog=False)
+ label='Gephi',
+ url='https://gephi.org',
+ indegree=1, frog=False)
cls.attribute_graph.add_node('1',
- label='Webatlas',
- url='http://webatlas.fr',
- indegree=2, frog=False)
+ label='Webatlas',
+ url='http://webatlas.fr',
+ indegree=2, frog=False)
cls.attribute_graph.add_node('2',
- label='RTGI',
- url='http://rtgi.fr',
- indegree=1, frog=True)
+ label='RTGI',
+ url='http://rtgi.fr',
+ indegree=1, frog=True)
cls.attribute_graph.add_node('3',
- label='BarabasiLab',
- url='http://barabasilab.com',
- indegree=1, frog=True)
+ label='BarabasiLab',
+ url='http://barabasilab.com',
+ indegree=1, frog=True)
cls.attribute_graph.add_edge('0', '1', id='0')
cls.attribute_graph.add_edge('0', '2', id='1')
cls.attribute_graph.add_edge('1', '0', id='2')
@@ -141,7 +141,7 @@ org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gexf.net/\
assert sorted(G.nodes()) == sorted(H.nodes())
assert sorted(G.edges()) == sorted(H.edges())
assert (sorted(G.edges(data=True)) ==
- sorted(H.edges(data=True)))
+ sorted(H.edges(data=True)))
self.simple_directed_fh.seek(0)
def test_write_read_simple_directed_graphml(self):
@@ -153,7 +153,7 @@ org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gexf.net/\
assert sorted(G.nodes()) == sorted(H.nodes())
assert sorted(G.edges()) == sorted(H.edges())
assert (sorted(G.edges(data=True)) ==
- sorted(H.edges(data=True)))
+ sorted(H.edges(data=True)))
self.simple_directed_fh.seek(0)
def test_read_simple_undirected_graphml(self):
diff --git a/networkx/readwrite/tests/test_gml.py b/networkx/readwrite/tests/test_gml.py
index 121f375f..4f2090ea 100644
--- a/networkx/readwrite/tests/test_gml.py
+++ b/networkx/readwrite/tests/test_gml.py
@@ -145,20 +145,20 @@ graph [
def test_parse_gml(self):
G = nx.parse_gml(self.simple_data, label='label')
assert (sorted(G.nodes()) ==
- ['Node 1', 'Node 2', 'Node 3'])
+ ['Node 1', 'Node 2', 'Node 3'])
assert ([e for e in sorted(G.edges())] ==
- [('Node 1', 'Node 2'),
- ('Node 2', 'Node 3'),
- ('Node 3', 'Node 1')])
+ [('Node 1', 'Node 2'),
+ ('Node 2', 'Node 3'),
+ ('Node 3', 'Node 1')])
assert ([e for e in sorted(G.edges(data=True))] ==
- [('Node 1', 'Node 2',
- {'color': {'line': 'blue', 'thickness': 3},
- 'label': 'Edge from node 1 to node 2'}),
- ('Node 2', 'Node 3',
- {'label': 'Edge from node 2 to node 3'}),
- ('Node 3', 'Node 1',
- {'label': 'Edge from node 3 to node 1'})])
+ [('Node 1', 'Node 2',
+ {'color': {'line': 'blue', 'thickness': 3},
+ 'label': 'Edge from node 1 to node 2'}),
+ ('Node 2', 'Node 3',
+ {'label': 'Edge from node 2 to node 3'}),
+ ('Node 3', 'Node 1',
+ {'label': 'Edge from node 3 to node 1'})])
def test_read_gml(self):
(fd, fname) = tempfile.mkstemp()
@@ -343,9 +343,9 @@ graph
assert data == G.name
assert {'name': data, str('data'): data} == G.graph
assert (list(G.nodes(data=True)) ==
- [(0, dict(int=-1, data=dict(data=data)))])
+ [(0, dict(int=-1, data=dict(data=data)))])
assert (list(G.edges(data=True)) ==
- [(0, 0, dict(float=-2.5, data=data))])
+ [(0, 0, dict(float=-2.5, data=data))])
G = nx.Graph()
G.graph['data'] = 'frozenset([1, 2, 3])'
G = nx.parse_gml(nx.generate_gml(G), destringizer=literal_eval)
diff --git a/networkx/readwrite/tests/test_graph6.py b/networkx/readwrite/tests/test_graph6.py
index 48c6976f..d0d2bab7 100644
--- a/networkx/readwrite/tests/test_graph6.py
+++ b/networkx/readwrite/tests/test_graph6.py
@@ -17,7 +17,7 @@ class TestGraph6Utils(object):
assert g6.data_to_n(g6.n_to_data(i))[0] == i
assert g6.data_to_n(g6.n_to_data(i))[1] == []
assert (g6.data_to_n(g6.n_to_data(i) + [42, 43])[1] ==
- [42, 43])
+ [42, 43])
class TestFromGraph6Bytes(TestCase):
@@ -97,7 +97,7 @@ class TestWriteGraph6(TestCase):
# Strip the trailing newline.
gstr = gstr.getvalue().rstrip()
assert (len(gstr) ==
- ((i - 1) * i // 2 + 5) // 6 + (1 if i < 63 else 4))
+ ((i - 1) * i // 2 + 5) // 6 + (1 if i < 63 else 4))
def test_roundtrip(self):
for i in list(range(13)) + [31, 47, 62, 63, 64, 72]:
diff --git a/networkx/readwrite/tests/test_graphml.py b/networkx/readwrite/tests/test_graphml.py
index 8c689888..6d1a4288 100644
--- a/networkx/readwrite/tests/test_graphml.py
+++ b/networkx/readwrite/tests/test_graphml.py
@@ -7,6 +7,7 @@ import tempfile
import os
from networkx.testing import almost_equal
+
class BaseGraphML(object):
@classmethod
def setup_class(cls):
@@ -45,15 +46,15 @@ class BaseGraphML(object):
cls.simple_directed_graph.add_node('n10')
cls.simple_directed_graph.add_edge('n0', 'n2', id='foo')
cls.simple_directed_graph.add_edges_from([('n1', 'n2'),
- ('n2', 'n3'),
- ('n3', 'n5'),
- ('n3', 'n4'),
- ('n4', 'n6'),
- ('n6', 'n5'),
- ('n5', 'n7'),
- ('n6', 'n8'),
- ('n8', 'n7'),
- ('n8', 'n9'),
+ ('n2', 'n3'),
+ ('n3', 'n5'),
+ ('n3', 'n4'),
+ ('n4', 'n6'),
+ ('n6', 'n5'),
+ ('n5', 'n7'),
+ ('n6', 'n8'),
+ ('n8', 'n7'),
+ ('n8', 'n9'),
])
cls.simple_directed_fh = \
io.BytesIO(cls.simple_directed_data.encode('UTF-8'))
@@ -170,7 +171,7 @@ class BaseGraphML(object):
cls.simple_undirected_graph.add_node('n10')
cls.simple_undirected_graph.add_edge('n0', 'n2', id='foo')
cls.simple_undirected_graph.add_edges_from([('n1', 'n2'),
- ('n2', 'n3'),
+ ('n2', 'n3'),
])
fh = io.BytesIO(cls.simple_undirected_data.encode('UTF-8'))
cls.simple_undirected_fh = fh
@@ -183,14 +184,14 @@ class TestReadGraphML(BaseGraphML):
assert sorted(G.nodes()) == sorted(H.nodes())
assert sorted(G.edges()) == sorted(H.edges())
assert (sorted(G.edges(data=True)) ==
- sorted(H.edges(data=True)))
+ sorted(H.edges(data=True)))
self.simple_directed_fh.seek(0)
I = nx.parse_graphml(self.simple_directed_data)
assert sorted(G.nodes()) == sorted(I.nodes())
assert sorted(G.edges()) == sorted(I.edges())
assert (sorted(G.edges(data=True)) ==
- sorted(I.edges(data=True)))
+ sorted(I.edges(data=True)))
def test_read_simple_undirected_graphml(self):
G = self.simple_undirected_graph
@@ -931,8 +932,8 @@ class TestWriteGraphML(BaseGraphML):
H = nx.read_graphml(fh)
assert H.nodes['n0']['special'] is False
assert H.nodes['n1']['special'] is 0
- assert H.edges['n0','n1',0]['special'] is False
- assert H.edges['n0','n1',1]['special'] is 0
+ assert H.edges['n0', 'n1', 0]['special'] is False
+ assert H.edges['n0', 'n1', 1]['special'] is 0
def test_multigraph_to_graph(self):
# test converting multigraph to graph if no parallel edges found
diff --git a/networkx/readwrite/tests/test_leda.py b/networkx/readwrite/tests/test_leda.py
index edf9318d..7e6bf144 100644
--- a/networkx/readwrite/tests/test_leda.py
+++ b/networkx/readwrite/tests/test_leda.py
@@ -10,15 +10,15 @@ class TestLEDA(object):
G = nx.parse_leda(data)
G = nx.parse_leda(data.split('\n'))
assert (sorted(G.nodes()) ==
- ['v1', 'v2', 'v3', 'v4', 'v5'])
+ ['v1', 'v2', 'v3', 'v4', 'v5'])
assert (sorted(G.edges(data=True)) ==
- [('v1', 'v2', {'label': '4'}),
- ('v1', 'v3', {'label': '3'}),
- ('v2', 'v3', {'label': '2'}),
- ('v3', 'v4', {'label': '3'}),
- ('v3', 'v5', {'label': '7'}),
- ('v4', 'v5', {'label': '6'}),
- ('v5', 'v1', {'label': 'foo'})])
+ [('v1', 'v2', {'label': '4'}),
+ ('v1', 'v3', {'label': '3'}),
+ ('v2', 'v3', {'label': '2'}),
+ ('v3', 'v4', {'label': '3'}),
+ ('v3', 'v5', {'label': '7'}),
+ ('v4', 'v5', {'label': '6'}),
+ ('v5', 'v1', {'label': 'foo'})])
def test_read_LEDA(self):
fh = io.BytesIO()
diff --git a/networkx/readwrite/tests/test_pajek.py b/networkx/readwrite/tests/test_pajek.py
index b4a69e15..bcb1b11d 100644
--- a/networkx/readwrite/tests/test_pajek.py
+++ b/networkx/readwrite/tests/test_pajek.py
@@ -15,8 +15,8 @@ class TestPajek(object):
cls.G = nx.MultiDiGraph()
cls.G.add_nodes_from(['A1', 'Bb', 'C', 'D2'])
cls.G.add_edges_from([('A1', 'A1'), ('A1', 'Bb'), ('A1', 'C'),
- ('Bb', 'A1'), ('C', 'C'), ('C', 'D2'),
- ('D2', 'Bb')])
+ ('Bb', 'A1'), ('C', 'C'), ('C', 'D2'),
+ ('D2', 'Bb')])
cls.G.graph['name'] = 'Tralala'
(fd, cls.fname) = tempfile.mkstemp()
@@ -61,7 +61,7 @@ class TestPajek(object):
import io
G = nx.parse_pajek(self.data)
fh = io.BytesIO()
- nx.write_pajek(G,fh)
+ nx.write_pajek(G, fh)
fh.seek(0)
H = nx.read_pajek(fh)
assert_nodes_equal(list(G), list(H))
@@ -80,7 +80,7 @@ class TestPajek(object):
import warnings
with warnings.catch_warnings(record=True) as w:
- nx.write_pajek(G,fh)
+ nx.write_pajek(G, fh)
assert len(w) == 4
def test_noname(self):
diff --git a/networkx/tests/test_all_random_functions.py b/networkx/tests/test_all_random_functions.py
index ec92d965..6d5146d2 100644
--- a/networkx/tests/test_all_random_functions.py
+++ b/networkx/tests/test_all_random_functions.py
@@ -19,7 +19,7 @@ py_rv = random.random()
def t(f, *args, **kwds):
- """call one function and check if global RNG changed"""
+ """call one function and check if global RNG changed"""
global progress
progress += 1
print(progress, ",", end="")
diff --git a/networkx/tests/test_convert.py b/networkx/tests/test_convert.py
index d79abfa6..bfa1ff27 100644
--- a/networkx/tests/test_convert.py
+++ b/networkx/tests/test_convert.py
@@ -236,9 +236,9 @@ class TestConvert():
assert self.edgelists_equal(nx.MultiGraph(nx.DiGraph(edges2)).edges(), edges1)
assert self.edgelists_equal(nx.MultiGraph(nx.MultiDiGraph(edges1)).edges(),
- edges1)
+ edges1)
assert self.edgelists_equal(nx.MultiGraph(nx.MultiDiGraph(edges2)).edges(),
- edges1)
+ edges1)
assert self.edgelists_equal(nx.Graph(nx.MultiDiGraph(edges1)).edges(), edges1)
assert self.edgelists_equal(nx.Graph(nx.MultiDiGraph(edges2)).edges(), edges1)
diff --git a/networkx/tests/test_convert_numpy.py b/networkx/tests/test_convert_numpy.py
index 49f92d69..c74b36ef 100644
--- a/networkx/tests/test_convert_numpy.py
+++ b/networkx/tests/test_convert_numpy.py
@@ -6,6 +6,7 @@ from networkx.testing.utils import assert_graphs_equal
#numpy = pytest.importorskip("numpy")
+
class TestConvertNumpy(object):
@classmethod
def setup_class(cls):
diff --git a/networkx/tests/test_relabel.py b/networkx/tests/test_relabel.py
index f9c14380..78beefcb 100644
--- a/networkx/tests/test_relabel.py
+++ b/networkx/tests/test_relabel.py
@@ -52,7 +52,7 @@ class TestRelabel():
assert H.degree(3) == 1
H = nx.convert_node_labels_to_integers(G, ordering="increasing degree",
- label_attribute='label')
+ label_attribute='label')
degH = (d for n, d in H.degree())
degG = (d for n, d in G.degree())
assert sorted(degH) == sorted(degG)
@@ -76,7 +76,7 @@ class TestRelabel():
assert sorted(degH) == sorted(degG)
H = nx.convert_node_labels_to_integers(G, ordering="sorted",
- label_attribute='label')
+ label_attribute='label')
assert H.nodes[0]['label'] == 'A'
assert H.nodes[1]['label'] == 'B'
assert H.nodes[2]['label'] == 'C'
diff --git a/networkx/utils/tests/test_decorators.py b/networkx/utils/tests/test_decorators.py
index aec968d0..2486e2c8 100644
--- a/networkx/utils/tests/test_decorators.py
+++ b/networkx/utils/tests/test_decorators.py
@@ -10,6 +10,7 @@ from networkx.utils.decorators import nodes_or_number, preserve_random_state, \
py_random_state, np_random_state, random_state
from networkx.utils.misc import PythonRandomInterface
+
def test_not_implemented_decorator():
@not_implemented_for('directed')
def test1(G):
@@ -169,7 +170,7 @@ class TestRandomState(object):
@py_random_state(1)
def instantiate_py_random_state(self, random_state):
assert (isinstance(random_state, random.Random) or
- isinstance(random_state, PythonRandomInterface))
+ isinstance(random_state, PythonRandomInterface))
return random_state.random()
def test_random_state_None(self):
diff --git a/networkx/utils/tests/test_misc.py b/networkx/utils/tests/test_misc.py
index 1de61473..17e059fc 100644
--- a/networkx/utils/tests/test_misc.py
+++ b/networkx/utils/tests/test_misc.py
@@ -202,6 +202,6 @@ def test_PythonRandomInterface():
assert rng.expovariate(1.5) == rs42.exponential(1/1.5)
assert np.all(rng.shuffle([1, 2, 3]) == rs42.shuffle([1, 2, 3]))
assert np.all(rng.sample([1, 2, 3], 2) ==
- rs42.choice([1, 2, 3], (2,), replace=False))
+ rs42.choice([1, 2, 3], (2,), replace=False))
assert rng.randint(3, 5) == rs42.randint(3, 6)
assert rng.random() == rs42.random_sample()
diff --git a/networkx/utils/tests/test_rcm.py b/networkx/utils/tests/test_rcm.py
index 16c1d87f..ce14812a 100644
--- a/networkx/utils/tests/test_rcm.py
+++ b/networkx/utils/tests/test_rcm.py
@@ -9,7 +9,7 @@ def test_reverse_cuthill_mckee():
(2, 4), (3, 5), (3, 8), (4, 6), (5, 6), (5, 7), (6, 7)])
rcm = list(reverse_cuthill_mckee_ordering(G))
assert rcm in [[0, 8, 5, 7, 3, 6, 2, 4, 1, 9],
- [0, 8, 5, 7, 3, 6, 4, 2, 1, 9]]
+ [0, 8, 5, 7, 3, 6, 4, 2, 1, 9]]
def test_rcm_alternate_heuristic():
diff --git a/networkx/utils/tests/test_unionfind.py b/networkx/utils/tests/test_unionfind.py
index 8620f374..59720ff0 100644
--- a/networkx/utils/tests/test_unionfind.py
+++ b/networkx/utils/tests/test_unionfind.py
@@ -11,6 +11,7 @@ def test_unionfind():
x = nx.utils.UnionFind()
x.union(0, 'a')
+
def test_subtree_union():
# See https://github.com/networkx/networkx/pull/3224
# (35db1b551ee65780794a357794f521d8768d5049).