Skip to content

Commit 151d10f

Browse files
committed
graphs/modular_decomposition: fix docstrings and syntax style
1 parent d88cfd3 commit 151d10f

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/sage/graphs/graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7186,7 +7186,7 @@ def cores(self, k=None, with_labels=False):
71867186
@doc_index("Modules")
71877187
def is_module(self, vertices):
71887188
r"""
7189-
Return whether ``vertices`` is a module of ``self``.
7189+
Check whether ``vertices`` is a module of ``self``.
71907190
71917191
A subset `M` of the vertices of a graph is a module if for every
71927192
vertex `v` outside of `M`, either all vertices of `M` are neighbors of
@@ -7267,11 +7267,11 @@ def is_module(self, vertices):
72677267
if len(M) == 0 or len(M) == 1 or len(M) == self.order():
72687268
return True
72697269

7270-
N = None # will contains the neighborhood of M
7270+
N = None # will contains the neighborhood of M
72717271
for v in M:
72727272
if N is None:
72737273
# first iteration, the neighborhood N must be computed
7274-
N = { u for u in self.neighbor_iterator(v) if u not in M }
7274+
N = {u for u in self.neighbor_iterator(v) if u not in M}
72757275
else:
72767276
# check that the neighborhood of v is N
72777277
n = 0

src/sage/graphs/graph_decompositions/modular_decomposition.pyx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class Node:
196196

197197
def is_prime(self):
198198
r"""
199-
Return ``True`` if the node is a prime node, ``False`` otherwise.
199+
Check whether ``self`` is a prime node.
200200
201201
EXAMPLES::
202202
@@ -213,7 +213,7 @@ class Node:
213213

214214
def is_series(self):
215215
r"""
216-
Return ``True`` if the node is series, ``False`` otherwise.
216+
Check whether ``self`` is a series node.
217217
218218
EXAMPLES::
219219
@@ -230,7 +230,7 @@ class Node:
230230

231231
def is_empty(self):
232232
r"""
233-
Return ``True`` if the node is empty, ``False`` otherwise.
233+
Check whether ``self`` is an empty node.
234234
235235
EXAMPLES::
236236
@@ -244,7 +244,7 @@ class Node:
244244

245245
def is_leaf(self):
246246
r"""
247-
Return ``True`` if the node is a leaf, ``False`` otherwise.
247+
Check whether ``self`` is a leaf.
248248
249249
EXAMPLES::
250250
@@ -638,14 +638,13 @@ def modular_decomposition(G, algorithm=None):
638638

639639
if not G.order():
640640
return Node(NodeType.EMPTY)
641-
elif G.order() == 1:
641+
if G.order() == 1:
642642
D = Node(NodeType.NORMAL)
643643
D.children.append(next(G.vertex_iterator()))
644644
return D
645-
elif algorithm == "habib_maurer":
645+
if algorithm == "habib_maurer":
646646
return habib_maurer_algorithm(G)
647-
else: # algorithm == "corneil_habib_paul_tedder"
648-
return corneil_habib_paul_tedder_algorithm(G)
647+
return corneil_habib_paul_tedder_algorithm(G)
649648

650649

651650
# ============================================================================
@@ -1400,9 +1399,8 @@ def md_tree_to_graph(root, prime_node_generator=None):
14001399

14011400
if root.is_empty():
14021401
return Graph()
1403-
else:
1404-
vs, es = tree_to_vertices_and_edges(root)
1405-
return Graph([vs, es], format='vertices_and_edges')
1402+
vs, es = tree_to_vertices_and_edges(root)
1403+
return Graph([vs, es], format='vertices_and_edges')
14061404

14071405

14081406
@random_testing

0 commit comments

Comments
 (0)