summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJarrod Millman <jarrod.millman@gmail.com>2023-02-14 12:52:22 -0800
committerGitHub <noreply@github.com>2023-02-14 12:52:22 -0800
commit79586c3f1a0f47e6643919887ace7e7e9335db8a (patch)
tree34bdd8f2afbaff5caa02bff01b1d8fe8c9f8b0ef /examples
parent44f0794f00a9fcba33a62f9d626ff882bee040ee (diff)
downloadnetworkx-79586c3f1a0f47e6643919887ace7e7e9335db8a.tar.gz
Update developer requirements (#6429)
* Update developer requirements * Run linter
Diffstat (limited to 'examples')
-rw-r--r--examples/drawing/plot_chess_masters.py4
-rw-r--r--examples/drawing/plot_knuth_miles.py2
-rw-r--r--examples/drawing/plot_multipartite_graph.py2
-rw-r--r--examples/drawing/plot_unix_email.py4
-rw-r--r--examples/graph/plot_morse_trie.py1
-rw-r--r--examples/graph/plot_words.py2
6 files changed, 8 insertions, 7 deletions
diff --git a/examples/drawing/plot_chess_masters.py b/examples/drawing/plot_chess_masters.py
index 7e7bfedc..a5f3b5a8 100644
--- a/examples/drawing/plot_chess_masters.py
+++ b/examples/drawing/plot_chess_masters.py
@@ -81,7 +81,7 @@ print(f"\nFrom a total of {len(openings)} different openings,")
print("the following games used the Sicilian opening")
print('with the Najdorff 7...Qb6 "Poisoned Pawn" variation.\n')
-for (white, black, game_info) in G.edges(data=True):
+for white, black, game_info in G.edges(data=True):
if game_info["ECO"] == "B97":
summary = f"{white} vs {black}\n"
for k, v in game_info.items():
@@ -97,7 +97,7 @@ edgewidth = [len(G.get_edge_data(u, v)) for u, v in H.edges()]
# node size is proportional to number of games won
wins = dict.fromkeys(G.nodes(), 0.0)
-for (u, v, d) in G.edges(data=True):
+for u, v, d in G.edges(data=True):
r = d["Result"].split("-")
if r[0] == "1":
wins[u] += 1.0
diff --git a/examples/drawing/plot_knuth_miles.py b/examples/drawing/plot_knuth_miles.py
index e0ebea87..90f26b41 100644
--- a/examples/drawing/plot_knuth_miles.py
+++ b/examples/drawing/plot_knuth_miles.py
@@ -79,7 +79,7 @@ print(G)
H = nx.Graph()
for v in G:
H.add_node(v)
-for (u, v, d) in G.edges(data=True):
+for u, v, d in G.edges(data=True):
if d["weight"] < 300:
H.add_edge(u, v)
diff --git a/examples/drawing/plot_multipartite_graph.py b/examples/drawing/plot_multipartite_graph.py
index 15c4d82c..a941bddc 100644
--- a/examples/drawing/plot_multipartite_graph.py
+++ b/examples/drawing/plot_multipartite_graph.py
@@ -25,7 +25,7 @@ def multilayered_graph(*subset_sizes):
extents = nx.utils.pairwise(itertools.accumulate((0,) + subset_sizes))
layers = [range(start, end) for start, end in extents]
G = nx.Graph()
- for (i, layer) in enumerate(layers):
+ for i, layer in enumerate(layers):
G.add_nodes_from(layer, layer=i)
for layer1, layer2 in nx.utils.pairwise(layers):
G.add_edges_from(itertools.product(layer1, layer2))
diff --git a/examples/drawing/plot_unix_email.py b/examples/drawing/plot_unix_email.py
index 25fce7ae..748b5491 100644
--- a/examples/drawing/plot_unix_email.py
+++ b/examples/drawing/plot_unix_email.py
@@ -43,7 +43,7 @@ def mbox_graph():
resent_ccs = msg.get_all("resent-cc", [])
all_recipients = getaddresses(tos + ccs + resent_tos + resent_ccs)
# now add the edges for this mail message
- for (target_name, target_addr) in all_recipients:
+ for target_name, target_addr in all_recipients:
G.add_edge(source_addr, target_addr, message=msg)
return G
@@ -52,7 +52,7 @@ def mbox_graph():
G = mbox_graph()
# print edges with message subject
-for (u, v, d) in G.edges(data=True):
+for u, v, d in G.edges(data=True):
print(f"From: {u} To: {v} Subject: {d['message']['Subject']}")
pos = nx.spring_layout(G, iterations=10, seed=227)
diff --git a/examples/graph/plot_morse_trie.py b/examples/graph/plot_morse_trie.py
index 88b424ce..22c1b998 100644
--- a/examples/graph/plot_morse_trie.py
+++ b/examples/graph/plot_morse_trie.py
@@ -77,6 +77,7 @@ nx.draw(G, pos=pos, with_labels=True)
elabels = {(u, v): l for u, v, l in G.edges(data="char")}
nx.draw_networkx_edge_labels(G, pos, edge_labels=elabels)
+
# A letter can be encoded by following the path from the given letter (node) to
# the root node
def morse_encode(letter):
diff --git a/examples/graph/plot_words.py b/examples/graph/plot_words.py
index e5211f59..19a49eb8 100644
--- a/examples/graph/plot_words.py
+++ b/examples/graph/plot_words.py
@@ -65,7 +65,7 @@ print("Two words are connected if they differ in one letter.")
print(G)
print(f"{nx.number_connected_components(G)} connected components")
-for (source, target) in [("chaos", "order"), ("nodes", "graph"), ("pound", "marks")]:
+for source, target in [("chaos", "order"), ("nodes", "graph"), ("pound", "marks")]:
print(f"Shortest path between {source} and {target} is")
try:
shortest_path = nx.shortest_path(G, source, target)