You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gh-39038: graphs: implementation of linear-time algorithm for modular decomposition
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes#12345". -->
This PR implements the recursive, linear-time algorithm to compute the
modular decomposition of simple undirected graphs from
[TCHP2008](https://arxiv.org/pdf/0710.3901).
A previous implementation was introduced in version 9.7 but was removed
after some bugs were discovered (see #25872 for exemple).
This implementation is based on an updated version of the article and is
intensively tested.
This PR contains:
- a implementation in C++ of the algorithm (in the file
`graph_decompositions/modular_decomposition.hpp`) and the corresponding
interface file `graph_decompositions/modular_decomposition.pxd`
- a small reorganization of the method `modular_decomposition` of the
class Graph: this method now accept a parameter `algorithm` (that can be
'habib_maurer' for the previous algorithm, or
'corneil_habib_paul_tedder' for the new one, which is the default
value), it then call the function `modular_decomposition` from
`graph_decompositions/modular_decomposition.pyx` which dispatch the call
to the correct function (`habib_maurer_algorithm` or `
corneil_habib_paul_tedder_algorithm`)
- a new parameter `algorithm` for the `is_prime` method (which is passed
directly to the `modular_decomposition` method)
- a new `is_module` method for the Graph class
- a small clean up of the file
`graph_decompositions/modular_decomposition.pyx` to remove unused field
of the `Node` class and useless functions.
- a new `prime_node_generator` parameter for the `md_tree_to_graph`
(used for generating modular decomposition tree for tests)
In this PR, I did not change the output of the `modular_decomposition`
method to keep the changes to a minimum.
If this PR is accepted, I intend to do it in another PR. The goal would
be to return a object that contains all the information of the modular
decomposition tree: currently the two formats for the output have no
information for the prime graph corresponding to prime nodes. It can be
computed from the output of the new algorithm but this information is
lost during the conversion to one of the output format of the method
`modular_decomposition`.
### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
### ⌛ Dependencies
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
URL: #39038
Reported by: cyrilbouvier
Reviewer(s): cyrilbouvier, David Coudert
0 commit comments