Repository navigation
ENH: Add is_perfect_graph using SPGT (follow-up to #8111) - #8318
Conversation
…string Refactors the `is_perfect_graph` function (originally proposed in PR networkx#8111) to use `nx.chordless_cycles` for induced odd-hole detection instead of the path-based enumeration approach. This improves clarity and efficiency while keeping the implementation faithful to the Strong Perfect Graph Theorem (SPGT).
Adds a third "Related Specialized Algorithms" section to the docstring of `is_perfect_graph`, mentioning existing recognition functions for chordal and bipartite. This clarifies the relationship between these subclasses and the general SPGT-based check.
Co-authored-by: Ross Barnowski <[email protected]>
Co-authored-by: Ross Barnowski <[email protected]>
Co-authored-by: Ross Barnowski <[email protected]>
Co-authored-by: Ross Barnowski <[email protected]>
|
Thanks for the detailed style feedback! |
|
Oops... forgot to check the docs. |
|
Thanks for catching that! |
|
Sorry -- I seem to have forgotten another step: The CI documentation artifact webpages still don't show the is_perfect_graph docs. and the Ci documentation (under build docs section log) says that Easy fix. |
I’ve added perfect_graph to doc/reference/algorithms/index.rst . |
Implements is_perfect_graph(G) based on the Strong Perfect Graph Theorem (SPGT).
The function returns True if and only if neither the graph nor its complement contains an induced odd chordless cycle (odd hole) of length ≥ 5.
This refines and completes the earlier proposal in #8111.
The current implementation runs in exponential time in the worst case, while the full SPGT recognition algorithm is polynomial (O(n⁹)) but too intricate to include here.