Skip to content

Conversation

@Ordoviz
Copy link
Contributor

@Ordoviz Ordoviz commented Sep 3, 2025

This fixes is_cactus() erroneously returning True for the following small disconnected graphs: Graph(2), Graph(3), Graph('BG').

I also added a special case for trees as a small performance improvement.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

@github-actions
Copy link

github-actions bot commented Sep 3, 2025

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

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 pushed a commit to vbraun/sage that referenced this pull request Sep 7, 2025
sagemathgh-40762: Fix is_cactus() for small disconnected graphs
    
This fixes [`is_cactus()`](https://doc-develop--sagemath.netlify.app/htm
l/en/reference/graphs/sage/graphs/graph#sage.graphs.graph.Graph.is_cactu
s) erroneously returning `True` for the following small disconnected
graphs: [`Graph(2)`](https://houseofgraphs.org/graphs/19653),
[`Graph(3)`](https://houseofgraphs.org/graphs/51081),
[`Graph('BG')`](https://houseofgraphs.org/graphs/49432).

I also added a special case for trees as a small performance
improvement.

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
    
URL: sagemath#40762
Reported by: Lennard Hofmann
Reviewer(s): David Coudert
@vbraun vbraun merged commit 7b37c06 into sagemath:develop Sep 14, 2025
22 of 25 checks passed
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.

3 participants