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

add parameter immutable to some graph operations in sage/graphs/generic_graph.py #39280

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

dcoudert
Copy link
Contributor

@dcoudert dcoudert commented Jan 4, 2025

As proposed in #39177, we add parameter immutable to (some) graph operations.

  • add tests to add_clique, add_path, and add_cycle to prevent modifying an immutable graph
  • add the parameter to method complement
  • ensure that method to_undirected behaves as expected
  • propose a more direct version of disjoint_union to ensure a correct behavior
  • ensure that method union behaves as expected

This is only a beginning. More to come in future PRs.

📝 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 Jan 5, 2025

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

@mantepse
Copy link
Collaborator

mantepse commented Jan 5, 2025

I must say that I would like it much better if graphs were immutable by default :-(

@dcoudert
Copy link
Contributor Author

dcoudert commented Jan 5, 2025

Before debating such drastic change, we must make sure that the entire graph library, including generators, is consistent.

@fchapoton
Copy link
Contributor

maybe you could create a function "scream_if_immutable" to avoid repeating ?

@@ -19440,6 +19472,17 @@ def complement(self):
Graph on 10 vertices
sage: g.complement()
Graph on 10 vertices

Check the behavior of parameter `ìmmutable``::

Copy link
Contributor

Choose a reason for hiding this comment

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

missing backtick

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done (3 times).

@dcoudert
Copy link
Contributor Author

dcoudert commented Jan 8, 2025

maybe you could create a function "scream_if_immutable" to avoid repeating ?

I'm adding this idea to my todo list. It should certainly be done also in backends...

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