Skip to content

Commit

Permalink
Trac #26534: avoid using .vertices() in weakly_chordal.pyx
Browse files Browse the repository at this point in the history
URL: https://trac.sagemath.org/26534
Reported by: dcoudert
Ticket author(s): David Coudert
Reviewer(s): Frédéric Chapoton
  • Loading branch information
Release Manager authored and vbraun committed Oct 24, 2018
2 parents d21a474 + df5a302 commit 1b62dfe
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/sage/graphs/weakly_chordal.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ def is_long_hole_free(g, certificate=False):
# documented in the module sage.graphs.base.static_sparse_graph.
# Vertices are relabeled in 0..n-1
cdef int n = g.order()
cdef list id_label = g.vertices()
cdef list id_label = list(g)
cdef dict label_id = {label: i for i, label in enumerate(id_label)}
cdef short_digraph sd
init_short_digraph(sd, g)
init_short_digraph(sd, g, edge_labelled=False, vertex_list=id_label)

# Make a dense copy of the graph for quick adjacency tests
cdef bitset_t dense_graph
Expand Down Expand Up @@ -369,7 +369,7 @@ cdef inline is_long_antihole_free_process(g, short_digraph sd, bitset_t dense_gr

return True, []

def is_long_antihole_free(g, certificate = False):
def is_long_antihole_free(g, certificate=False):
r"""
Tests whether the given graph contains an induced subgraph that is
isomorphic to the complement of a cycle of length at least 5.
Expand Down Expand Up @@ -418,7 +418,7 @@ def is_long_antihole_free(g, certificate = False):
sage: r,a = g.is_long_antihole_free(certificate=True)
sage: r
False
sage: a.complement().is_isomorphic( graphs.CycleGraph(6) )
sage: a.complement().is_isomorphic(graphs.CycleGraph(6))
True
TESTS:
Expand All @@ -429,7 +429,7 @@ def is_long_antihole_free(g, certificate = False):
sage: r,a = g.is_long_antihole_free(certificate=True)
sage: r
False
sage: a.complement().is_isomorphic( graphs.CycleGraph(9) )
sage: a.complement().is_isomorphic(graphs.CycleGraph(9))
True
sage: graphs.EmptyGraph().is_long_hole_free()
Expand All @@ -446,10 +446,10 @@ def is_long_antihole_free(g, certificate = False):
# documented in the module sage.graphs.base.static_sparse_graph.
# Vertices are relabeled in 0..n-1
cdef int n = g.order()
cdef list id_label = g.vertices()
cdef list id_label = list(g)
cdef dict label_id = {label: i for i, label in enumerate(id_label)}
cdef short_digraph sd
init_short_digraph(sd, g)
init_short_digraph(sd, g, edge_labelled=False, vertex_list=id_label)

# Make a dense copy of the graph for quick adjacency tests
cdef bitset_t dense_graph
Expand Down Expand Up @@ -516,7 +516,7 @@ def is_long_antihole_free(g, certificate = False):
else:
return True

def is_weakly_chordal(g, certificate = False):
def is_weakly_chordal(g, certificate=False):
r"""
Tests whether the given graph is weakly chordal, i.e., the graph and its
complement have no induced cycle of length at least 5.
Expand Down Expand Up @@ -545,11 +545,11 @@ def is_weakly_chordal(g, certificate = False):
The Petersen Graph is not weakly chordal and contains a hole::
sage: g = graphs.PetersenGraph()
sage: r,s = g.is_weakly_chordal(certificate = True)
sage: r,s = g.is_weakly_chordal(certificate=True)
sage: r
False
sage: l = len(s.vertices())
sage: s.is_isomorphic( graphs.CycleGraph(l) )
sage: l = s.order()
sage: s.is_isomorphic(graphs.CycleGraph(l))
True
TESTS::
Expand Down

0 comments on commit 1b62dfe

Please sign in to comment.