Skip to content

add parameter immutable to graph generators in random.py#41739

Merged
vbraun merged 23 commits intosagemath:developfrom
dcoudert:graphs/immutable_in_random
Mar 22, 2026
Merged

add parameter immutable to graph generators in random.py#41739
vbraun merged 23 commits intosagemath:developfrom
dcoudert:graphs/immutable_in_random

Conversation

@dcoudert
Copy link
Copy Markdown
Collaborator

@dcoudert dcoudert commented Mar 2, 2026

Following discussions in #39177, we add the option to return immutable graphs to all generators in src/sage/graphs/generators/random.py.

I agree it is a large PR, but most of the changes are straightforward, except for RandomBipartite, RandomBlockGraph, RandomKTree, RandomPartialKTree.

A set of tests for checking the behavior of parameter immutable will be added to generators_test.py for all generators in a follow-up PR.

📝 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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

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

Copy link
Copy Markdown
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

Two very minor things.

Comment thread src/sage/graphs/generators/random.py Outdated
else:
raise ValueError("'algorithm' must be equal to 'networkx' or to 'Sage'.")
return sageGNP(n, p, seed=seed, immutable=immutable)
raise ValueError("'algorithm' must be equal to 'networkx' or to 'Sage'.")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
raise ValueError("'algorithm' must be equal to 'networkx' or to 'Sage'.")
raise ValueError("'algorithm' must be equal to 'networkx' or to 'Sage'")

A while-we-are-at-it change.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment thread src/sage/graphs/generators/random.py Outdated

g = ToleranceGraph(tolrep)
g.name("Random tolerance graph")
g = ToleranceGraph(tolrep, immutable=immutable)
Copy link
Copy Markdown
Collaborator

@tscrim tscrim Mar 3, 2026

Choose a reason for hiding this comment

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

ToleranceGraph won't take a name parameter after all of these immutable keyword changes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

right. I added parameter name to ToleranceGraph

@dcoudert
Copy link
Copy Markdown
Collaborator Author

dcoudert commented Mar 3, 2026

Thanks for the review. I also fixed an issue with RandomPartialKTree: ensure that mutable/immutable graphs have the same set of vertices.

@tscrim
Copy link
Copy Markdown
Collaborator

tscrim commented Mar 3, 2026

Thank you. Positive review.

vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 6, 2026
sagemathgh-41739: add parameter immutable to graph generators in `random.py`
    
Following discussions in sagemath#39177, we add the option to return immutable
graphs to all generators in `src/sage/graphs/generators/random.py`.

I agree it is a large PR, but most of the changes are straightforward,
except for `RandomBipartite`, `RandomBlockGraph`, `RandomKTree`,
`RandomPartialKTree`.

A set of tests for checking the behavior of parameter immutable will be
added to `generators_test.py` for all generators in a follow-up PR.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] 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

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#41739
Reported by: David Coudert
Reviewer(s): David Coudert, Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 15, 2026
sagemathgh-41739: add parameter immutable to graph generators in `random.py`
    
Following discussions in sagemath#39177, we add the option to return immutable
graphs to all generators in `src/sage/graphs/generators/random.py`.

I agree it is a large PR, but most of the changes are straightforward,
except for `RandomBipartite`, `RandomBlockGraph`, `RandomKTree`,
`RandomPartialKTree`.

A set of tests for checking the behavior of parameter immutable will be
added to `generators_test.py` for all generators in a follow-up PR.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] 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

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#41739
Reported by: David Coudert
Reviewer(s): David Coudert, Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 18, 2026
sagemathgh-41739: add parameter immutable to graph generators in `random.py`
    
Following discussions in sagemath#39177, we add the option to return immutable
graphs to all generators in `src/sage/graphs/generators/random.py`.

I agree it is a large PR, but most of the changes are straightforward,
except for `RandomBipartite`, `RandomBlockGraph`, `RandomKTree`,
`RandomPartialKTree`.

A set of tests for checking the behavior of parameter immutable will be
added to `generators_test.py` for all generators in a follow-up PR.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] 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

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#41739
Reported by: David Coudert
Reviewer(s): David Coudert, Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 21, 2026
sagemathgh-41739: add parameter immutable to graph generators in `random.py`
    
Following discussions in sagemath#39177, we add the option to return immutable
graphs to all generators in `src/sage/graphs/generators/random.py`.

I agree it is a large PR, but most of the changes are straightforward,
except for `RandomBipartite`, `RandomBlockGraph`, `RandomKTree`,
`RandomPartialKTree`.

A set of tests for checking the behavior of parameter immutable will be
added to `generators_test.py` for all generators in a follow-up PR.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] 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

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#41739
Reported by: David Coudert
Reviewer(s): David Coudert, Travis Scrimshaw
@vbraun vbraun merged commit 8be5256 into sagemath:develop Mar 22, 2026
24 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