Skip to content

Commit 2f604dd

Browse files
author
Release Manager
committed
gh-35965: Minor changes in is_chordal We update the documentation of `is_chordal` since we now have a true linear time implementation of `lex BFS`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35965 Reported by: David Coudert Reviewer(s): Dima Pasechnik
2 parents dd82378 + dfac751 commit 2f604dd

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
@@ -14227,20 +14227,18 @@ def is_chordal(self, certificate=False, algorithm="B"):
1422714227
a hole.
1422814228

1422914229
- ``algorithm`` -- string (default: ``"B"``); the algorithm to choose
14230-
among ``"A"`` or ``"B"`` (see next section). While they will agree on
14231-
whether the given graph is chordal, they cannot be expected to return
14232-
the same certificates.
14230+
among ``"A"`` or ``"B"``. While they will agree on whether the given
14231+
graph is chordal, they cannot be expected to return the same
14232+
certificates.
1423314233

1423414234
ALGORITHM:
1423514235

14236-
This algorithm works through computing a Lex BFS on the graph, then
14237-
checking whether the order is a Perfect Elimination Order by computing
14238-
for each vertex `v` the subgraph induces by its non-deleted neighbors,
14239-
then testing whether this graph is complete.
14240-
14241-
This problem can be solved in `O(m)` [RT1975]_ ( where `m` is the number
14242-
of edges in the graph ) but this implementation is not linear because of
14243-
the complexity of Lex BFS.
14236+
This method implements the algorithm proposed in [RT1975]_ for the
14237+
recognition of chordal graphs with time complexity in `O(m)`. The
14238+
algorithm works through computing a Lex BFS on the graph, then checking
14239+
whether the order is a Perfect Elimination Order by computing for each
14240+
vertex `v` the subgraph induced by its non-deleted neighbors, then
14241+
testing whether this graph is complete.
1424414242

1424514243
EXAMPLES:
1424614244

@@ -14354,7 +14352,7 @@ def is_chordal(self, certificate=False, algorithm="B"):
1435414352
continue
1435514353

1435614354
x = next(t_peo.neighbor_out_iterator(v))
14357-
S = self.neighbors(x) + [x]
14355+
S = self.neighbors(x, closed=True)
1435814356

1435914357
if not frozenset(g.neighbor_iterator(v)).issubset(S):
1436014358

@@ -14390,7 +14388,7 @@ def is_chordal(self, certificate=False, algorithm="B"):
1439014388
peo, t_peo = self.lex_BFS(reverse=True, tree=True)
1439114389

1439214390
# Remembering the (closed) neighborhoods of each vertex
14393-
neighbors_subsets = {v: frozenset(self.neighbors(v) + [v]) for v in g}
14391+
neighbors_subsets = {v: frozenset(self.neighbor_iterator(v, closed=True)) for v in g}
1439414392
pos_in_peo = dict(zip(peo, range(self.order())))
1439514393

1439614394
# Iteratively removing vertices and checking everything is fine.

0 commit comments

Comments
 (0)