graphs: implementation of linear-time algorithm for modular decomposition #39038
+1,261
−339
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the recursive, linear-time algorithm to compute the modular decomposition of simple undirected graphs from TCHP2008.
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:
graph_decompositions/modular_decomposition.hpp
) and the corresponding interface filegraph_decompositions/modular_decomposition.pxd
modular_decomposition
of the class Graph: this method now accept a parameteralgorithm
(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 functionmodular_decomposition
fromgraph_decompositions/modular_decomposition.pyx
which dispatch the call to the correct function (habib_maurer_algorithm
orcorneil_habib_paul_tedder_algorithm
)algorithm
for theis_prime
method (which is passed directly to themodular_decomposition
method)is_module
method for the Graph classgraph_decompositions/modular_decomposition.pyx
to remove unused field of theNode
class and useless functions.prime_node_generator
parameter for themd_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
⌛ Dependencies