Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graph: modular decomposition of a single vertex should be a single tree node #38301

Merged
merged 2 commits into from
Jul 24, 2024

Conversation

cyrilbouvier
Copy link
Contributor

The modular decomposition tree computed by Sage for a graph with a single vertex is wrong (tested in Sage from 9.8-10.4.rc0)

sage: Graph(1).modular_decomposition()
(PRIME, [0])

Sage returns a tree with a PRIME root with a single child representing the vertex 0, but according to the recursive definition of a modular decomposition tree, it should be a single node tree (see Wikipedia for example)

This PR fixes this issue. It is an easy fix, as the case of single vertex graphs was treated separately in the modular_decomposition method of Graph.
Two doctests were modified to reflect this changes.

📝 Checklist

  • The title is concise and informative.
  • 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.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Copy link

github-actions bot commented Jun 28, 2024

Documentation preview for this PR (built with commit 420692b; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

src/sage/graphs/graph.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dcoudert dcoudert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@vbraun vbraun merged commit 22dbf40 into sagemath:develop Jul 24, 2024
19 of 22 checks passed
@mkoeppe mkoeppe added this to the sage-10.5 milestone Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants