Skip to content

Commit df43bcb

Browse files
committed
some care in traversals.pyx
1 parent 7ca8f0e commit df43bcb

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

src/sage/graphs/traversals.pyx

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ def lex_BFS(G, reverse=False, tree=False, initial_vertex=None, algorithm="fast")
475475
edges = [(int_to_v[i], int_to_v[pred[i]]) for i in range(n) if pred[i] != i]
476476
g = DiGraph([G, edges], format='vertices_and_edges', sparse=True)
477477
return sigma, g
478-
else:
479-
return sigma
478+
return sigma
480479

481480

482481
def lex_UP(G, reverse=False, tree=False, initial_vertex=None):
@@ -597,8 +596,7 @@ def lex_UP(G, reverse=False, tree=False, initial_vertex=None):
597596
from sage.graphs.digraph import DiGraph
598597
g = DiGraph(sparse=True)
599598
return [], g
600-
else:
601-
return []
599+
return []
602600

603601
# Build adjacency list of G
604602
cdef list int_to_v = list(G)
@@ -649,9 +647,7 @@ def lex_UP(G, reverse=False, tree=False, initial_vertex=None):
649647
edges = [(int_to_v[i], int_to_v[pred[i]]) for i in range(nV) if pred[i] != -1]
650648
g.add_edges(edges)
651649
return value, g
652-
653-
else:
654-
return value
650+
return value
655651

656652

657653
def lex_DFS(G, reverse=False, tree=False, initial_vertex=None):
@@ -771,8 +767,7 @@ def lex_DFS(G, reverse=False, tree=False, initial_vertex=None):
771767
from sage.graphs.digraph import DiGraph
772768
g = DiGraph(sparse=True)
773769
return [], g
774-
else:
775-
return []
770+
return []
776771

777772
# Build adjacency list of G
778773
cdef list int_to_v = list(G)
@@ -824,9 +819,7 @@ def lex_DFS(G, reverse=False, tree=False, initial_vertex=None):
824819
edges = [(int_to_v[i], int_to_v[pred[i]]) for i in range(nV) if pred[i] != -1]
825820
g.add_edges(edges)
826821
return value, g
827-
828-
else:
829-
return value
822+
return value
830823

831824

832825
def lex_DOWN(G, reverse=False, tree=False, initial_vertex=None):
@@ -947,8 +940,7 @@ def lex_DOWN(G, reverse=False, tree=False, initial_vertex=None):
947940
from sage.graphs.digraph import DiGraph
948941
g = DiGraph(sparse=True)
949942
return [], g
950-
else:
951-
return []
943+
return []
952944

953945
# Build adjacency list of G
954946
cdef list int_to_v = list(G)
@@ -1000,9 +992,7 @@ def lex_DOWN(G, reverse=False, tree=False, initial_vertex=None):
1000992
edges = [(int_to_v[i], int_to_v[pred[i]]) for i in range(nV) if pred[i] != -1]
1001993
g.add_edges(edges)
1002994
return value, g
1003-
1004-
else:
1005-
return value
995+
return value
1006996

1007997

1008998
def lex_M(self, triangulation=False, labels=False, initial_vertex=None, algorithm=None):
@@ -1151,10 +1141,9 @@ def lex_M(self, triangulation=False, labels=False, initial_vertex=None, algorith
11511141

11521142
if algorithm == "lex_M_slow":
11531143
return lex_M_slow(self, triangulation=triangulation, labels=labels, initial_vertex=initial_vertex)
1154-
else:
1155-
if labels:
1156-
raise ValueError("'{}' cannot return labels assigned to vertices".format(algorithm))
1157-
return lex_M_fast(self, triangulation=triangulation, initial_vertex=initial_vertex)
1144+
if labels:
1145+
raise ValueError("'{}' cannot return labels assigned to vertices".format(algorithm))
1146+
return lex_M_fast(self, triangulation=triangulation, initial_vertex=initial_vertex)
11581147

11591148

11601149
def lex_M_slow(G, triangulation=False, labels=False, initial_vertex=None):
@@ -1317,8 +1306,7 @@ def lex_M_slow(G, triangulation=False, labels=False, initial_vertex=None):
13171306
return alpha, F
13181307
elif labels:
13191308
return alpha, label
1320-
else:
1321-
return alpha
1309+
return alpha
13221310

13231311

13241312
def lex_M_fast(G, triangulation=False, initial_vertex=None):
@@ -1522,8 +1510,7 @@ def lex_M_fast(G, triangulation=False, initial_vertex=None):
15221510

15231511
if triangulation:
15241512
return ordering, F
1525-
else:
1526-
return ordering
1513+
return ordering
15271514

15281515

15291516
def is_valid_lex_M_order(G, alpha, F):

0 commit comments

Comments
 (0)