Skip to content

Commit dfac751

Browse files
committed
some corrections in is_chordal
1 parent 1ca4a47 commit dfac751

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/sage/graphs/generic_graph.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14217,20 +14217,18 @@ def is_chordal(self, certificate=False, algorithm="B"):
1421714217
a hole.
1421814218

1421914219
- ``algorithm`` -- string (default: ``"B"``); the algorithm to choose
14220-
among ``"A"`` or ``"B"`` (see next section). While they will agree on
14221-
whether the given graph is chordal, they cannot be expected to return
14222-
the same certificates.
14220+
among ``"A"`` or ``"B"``. While they will agree on whether the given
14221+
graph is chordal, they cannot be expected to return the same
14222+
certificates.
1422314223

1422414224
ALGORITHM:
1422514225

14226-
This algorithm works through computing a Lex BFS on the graph, then
14227-
checking whether the order is a Perfect Elimination Order by computing
14228-
for each vertex `v` the subgraph induces by its non-deleted neighbors,
14229-
then testing whether this graph is complete.
14230-
14231-
This problem can be solved in `O(m)` [RT1975]_ ( where `m` is the number
14232-
of edges in the graph ) but this implementation is not linear because of
14233-
the complexity of Lex BFS.
14226+
This method implements the algorithm proposed in [RT1975]_ for the
14227+
recognition of chordal graphs with time complexity in `O(m)`. The
14228+
algorithm works through computing a Lex BFS on the graph, then checking
14229+
whether the order is a Perfect Elimination Order by computing for each
14230+
vertex `v` the subgraph induced by its non-deleted neighbors, then
14231+
testing whether this graph is complete.
1423414232

1423514233
EXAMPLES:
1423614234

@@ -14344,7 +14342,7 @@ def is_chordal(self, certificate=False, algorithm="B"):
1434414342
continue
1434514343

1434614344
x = next(t_peo.neighbor_out_iterator(v))
14347-
S = self.neighbors(x) + [x]
14345+
S = self.neighbors(x, closed=True)
1434814346

1434914347
if not frozenset(g.neighbor_iterator(v)).issubset(S):
1435014348

@@ -14380,7 +14378,7 @@ def is_chordal(self, certificate=False, algorithm="B"):
1438014378
peo, t_peo = self.lex_BFS(reverse=True, tree=True)
1438114379

1438214380
# Remembering the (closed) neighborhoods of each vertex
14383-
neighbors_subsets = {v: frozenset(self.neighbors(v) + [v]) for v in g}
14381+
neighbors_subsets = {v: frozenset(self.neighbor_iterator(v, closed=True)) for v in g}
1438414382
pos_in_peo = dict(zip(peo, range(self.order())))
1438514383

1438614384
# Iteratively removing vertices and checking everything is fine.

0 commit comments

Comments
 (0)