Skip to content

Commit 5a29c79

Browse files
committed
style: code formatting
1 parent a78b025 commit 5a29c79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+320
-241
lines changed

doc/examples_sphinx-gallery/articulation_points.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
This example shows how to compute and visualize the `articulation points <https://en.wikipedia.org/wiki/Biconnected_component>`_ in a graph using :meth:`igraph.GraphBase.articulation_points`. For an example on bridges instead, see :ref:`tutorials-bridges`.
99
1010
"""
11+
1112
import igraph as ig
1213
import matplotlib.pyplot as plt
1314

@@ -30,9 +31,9 @@
3031
vertex_size=30,
3132
vertex_color="lightblue",
3233
vertex_label=range(g.vcount()),
33-
vertex_frame_color = ["red" if v in articulation_points else "black" for v in g.vs],
34-
vertex_frame_width = [3 if v in articulation_points else 1 for v in g.vs],
34+
vertex_frame_color=["red" if v in articulation_points else "black" for v in g.vs],
35+
vertex_frame_width=[3 if v in articulation_points else 1 for v in g.vs],
3536
edge_width=0.8,
36-
edge_color='gray'
37+
edge_color="gray",
3738
)
3839
plt.show()

doc/examples_sphinx-gallery/betweenness.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
# :meth:`igraph.utils.rescale` to rescale the betweennesses in the interval
2525
# ``[0, 1]``.
2626
def plot_betweenness(g, vertex_betweenness, edge_betweenness, ax, cax1, cax2):
27-
'''Plot vertex/edge betweenness, with colorbars
27+
"""Plot vertex/edge betweenness, with colorbars
2828
2929
Args:
3030
g: the graph to plot.
3131
ax: the Axes for the graph
3232
cax1: the Axes for the vertex betweenness colorbar
3333
cax2: the Axes for the edge betweenness colorbar
34-
'''
34+
"""
3535

3636
# Rescale betweenness to be between 0.0 and 1.0
3737
scaled_vertex_betweenness = ig.rescale(vertex_betweenness, clamp=True)
@@ -45,7 +45,7 @@ def plot_betweenness(g, vertex_betweenness, edge_betweenness, ax, cax1, cax2):
4545

4646
# Plot graph
4747
g.vs["color"] = [cmap1(betweenness) for betweenness in scaled_vertex_betweenness]
48-
g.vs["size"] = ig.rescale(vertex_betweenness, (10, 50))
48+
g.vs["size"] = ig.rescale(vertex_betweenness, (10, 50))
4949
g.es["color"] = [cmap2(betweenness) for betweenness in scaled_edge_betweenness]
5050
g.es["width"] = ig.rescale(edge_betweenness, (0.5, 1.0))
5151
ig.plot(
@@ -58,8 +58,8 @@ def plot_betweenness(g, vertex_betweenness, edge_betweenness, ax, cax1, cax2):
5858
# Color bars
5959
norm1 = ScalarMappable(norm=Normalize(0, max(vertex_betweenness)), cmap=cmap1)
6060
norm2 = ScalarMappable(norm=Normalize(0, max(edge_betweenness)), cmap=cmap2)
61-
plt.colorbar(norm1, cax=cax1, orientation="horizontal", label='Vertex Betweenness')
62-
plt.colorbar(norm2, cax=cax2, orientation="horizontal", label='Edge Betweenness')
61+
plt.colorbar(norm1, cax=cax1, orientation="horizontal", label="Vertex Betweenness")
62+
plt.colorbar(norm2, cax=cax2, orientation="horizontal", label="Edge Betweenness")
6363

6464

6565
# %%

doc/examples_sphinx-gallery/bipartite_matching.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
This example demonstrates an efficient way to find and visualise a maximum biparite matching using :meth:`igraph.Graph.maximum_bipartite_matching`.
99
"""
10+
1011
import igraph as ig
1112
import matplotlib.pyplot as plt
1213

@@ -16,7 +17,7 @@
1617
# - nodes 5-8 to the other side
1718
g = ig.Graph.Bipartite(
1819
[0, 0, 0, 0, 0, 1, 1, 1, 1],
19-
[(0, 5), (1, 6), (1, 7), (2, 5), (2, 8), (3, 6), (4, 5), (4, 6)]
20+
[(0, 5), (1, 6), (1, 7), (2, 5), (2, 8), (3, 6), (4, 5), (4, 6)],
2021
)
2122

2223
# %%

doc/examples_sphinx-gallery/bipartite_matching_maxflow.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
.. note:: :meth:`igraph.Graph.maximum_bipartite_matching` is usually a better way to find the maximum bipartite matching. For a demonstration on how to use that method instead, check out :ref:`tutorials-bipartite-matching`.
1111
"""
12+
1213
import igraph as ig
1314
import matplotlib.pyplot as plt
1415

@@ -17,7 +18,7 @@
1718
g = ig.Graph(
1819
9,
1920
[(0, 4), (0, 5), (1, 4), (1, 6), (1, 7), (2, 5), (2, 7), (2, 8), (3, 6), (3, 7)],
20-
directed=True
21+
directed=True,
2122
)
2223

2324
# %%
@@ -62,6 +63,6 @@
6263
vertex_size=30,
6364
vertex_label=range(g.vcount()),
6465
vertex_color=["lightblue" if i < 9 else "orange" for i in range(11)],
65-
edge_width=[1.0 + flow.flow[i] for i in range(g.ecount())]
66+
edge_width=[1.0 + flow.flow[i] for i in range(g.ecount())],
6667
)
6768
plt.show()

doc/examples_sphinx-gallery/bridges.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
This example shows how to compute and visualize the `bridges <https://en.wikipedia.org/wiki/Bridge_(graph_theory)>`_ in a graph using :meth:`igraph.GraphBase.bridges`. For an example on articulation points instead, see :ref:`tutorials-articulation-points`.
99
"""
10+
1011
import igraph as ig
1112
import matplotlib.pyplot as plt
1213

@@ -37,7 +38,7 @@
3738
target=ax,
3839
vertex_size=30,
3940
vertex_color="lightblue",
40-
vertex_label=range(g.vcount())
41+
vertex_label=range(g.vcount()),
4142
)
4243
plt.show()
4344

@@ -72,9 +73,9 @@
7273
vertex_size=30,
7374
vertex_color="lightblue",
7475
vertex_label=range(g.vcount()),
75-
edge_background="#FFF0", # transparent background color
76-
edge_align_label=True, # make sure labels are aligned with the edge
76+
edge_background="#FFF0", # transparent background color
77+
edge_align_label=True, # make sure labels are aligned with the edge
7778
edge_label=g.es["label"],
78-
edge_label_color="red"
79+
edge_label_color="red",
7980
)
8081
plt.show()

doc/examples_sphinx-gallery/cluster_contraction.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
This example shows how to find the communities in a graph, then contract each community into a single node using :class:`igraph.clustering.VertexClustering`. For this tutorial, we'll use the *Donald Knuth's Les Miserables Network*, which shows the coapperances of characters in the novel *Les Miserables*.
99
"""
10+
1011
import igraph as ig
1112
import matplotlib.pyplot as plt
1213

@@ -106,7 +107,10 @@
106107
# Finally, we can assign colors to the clusters and plot the cluster graph,
107108
# including a legend to make things clear:
108109
palette2 = ig.GradientPalette("gainsboro", "black")
109-
g.es["color"] = [palette2.get(int(i)) for i in ig.rescale(cluster_graph.es["size"], (0, 255), clamp=True)]
110+
g.es["color"] = [
111+
palette2.get(int(i))
112+
for i in ig.rescale(cluster_graph.es["size"], (0, 255), clamp=True)
113+
]
110114

111115
fig2, ax2 = plt.subplots()
112116
ig.plot(
@@ -123,7 +127,8 @@
123127
legend_handles = []
124128
for i in range(num_communities):
125129
handle = ax2.scatter(
126-
[], [],
130+
[],
131+
[],
127132
s=100,
128133
facecolor=palette1.get(i),
129134
edgecolor="k",
@@ -133,7 +138,7 @@
133138

134139
ax2.legend(
135140
handles=legend_handles,
136-
title='Community:',
141+
title="Community:",
137142
bbox_to_anchor=(0, 1.0),
138143
bbox_transform=ax2.transAxes,
139144
)

doc/examples_sphinx-gallery/complement.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
This example shows how to generate the `complement graph <https://en.wikipedia.org/wiki/Complement_graph>`_ of a graph (sometimes known as the anti-graph) using :meth:`igraph.GraphBase.complementer`.
99
"""
10+
1011
import igraph as ig
1112
import matplotlib.pyplot as plt
1213
import random
@@ -49,27 +50,27 @@
4950
layout="circle",
5051
vertex_color="black",
5152
)
52-
axs[0, 0].set_title('Original graph')
53+
axs[0, 0].set_title("Original graph")
5354
ig.plot(
5455
g2,
5556
target=axs[0, 1],
5657
layout="circle",
5758
vertex_color="black",
5859
)
59-
axs[0, 1].set_title('Complement graph')
60+
axs[0, 1].set_title("Complement graph")
6061

6162
ig.plot(
6263
g_full,
6364
target=axs[1, 0],
6465
layout="circle",
6566
vertex_color="black",
6667
)
67-
axs[1, 0].set_title('Union graph')
68+
axs[1, 0].set_title("Union graph")
6869
ig.plot(
6970
g_empty,
7071
target=axs[1, 1],
7172
layout="circle",
7273
vertex_color="black",
7374
)
74-
axs[1, 1].set_title('Complement of union graph')
75+
axs[1, 1].set_title("Complement of union graph")
7576
plt.show()

doc/examples_sphinx-gallery/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
This example shows how to use igraph's :class:`configuration instance <igraph.Configuration>` to set default igraph settings. This is useful for setting global settings so that they don't need to be explicitly stated at the beginning of every igraph project you work on.
99
"""
10+
1011
import igraph as ig
1112
import matplotlib.pyplot as plt
1213
import random

doc/examples_sphinx-gallery/connected_components.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
This example demonstrates how to visualise the connected components in a graph using :meth:`igraph.GraphBase.connected_components`.
99
"""
10+
1011
import igraph as ig
1112
import matplotlib.pyplot as plt
1213
import random
@@ -21,7 +22,7 @@
2122
# %%
2223
# Now we can cluster the graph into weakly connected components, i.e. subgraphs
2324
# that have no edges connecting them to one another:
24-
components = g.connected_components(mode='weak')
25+
components = g.connected_components(mode="weak")
2526

2627
# %%
2728
# Finally, we can visualize the distinct connected components of the graph:

doc/examples_sphinx-gallery/delaunay-triangulation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
This example demonstrates how to calculate the `Delaunay triangulation <https://en.wikipedia.org/wiki/Delaunay_triangulation>`_ of an input graph. We start by generating a set of points on a 2D grid using random ``numpy`` arrays and a graph with those vertex coordinates and no edges.
99
1010
"""
11+
1112
import numpy as np
1213
from scipy.spatial import Delaunay
1314
import igraph as ig
@@ -20,8 +21,8 @@
2021
np.random.seed(0)
2122
x, y = np.random.rand(2, 30)
2223
g = ig.Graph(30)
23-
g.vs['x'] = x
24-
g.vs['y'] = y
24+
g.vs["x"] = x
25+
g.vs["y"] = y
2526

2627
# %%
2728
# Because we already set the `x` and `y` vertex attributes, we can use

0 commit comments

Comments
 (0)