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 support for immutable=True/False parameter in .canonical_label() and other functions that create a new graph #39177

Open
1 task done
maxale opened this issue Dec 20, 2024 · 0 comments

Comments

@maxale
Copy link
Contributor

maxale commented Dec 20, 2024

Problem Description

Since Graph().canonical_label(immutable=True) gives

TypeError: GenericGraph.canonical_label() got an unexpected keyword argument 'immutable'

one is forced to use an additional .copy() call like Graph().canonical_label().copy(immutable=True) to get an immutable canonical label of a given graph.

Proposed Solution

It will be more straightforward to have immutable= keyword argument supported by any function that creates and returns a new graph (like .canonical_copy()) to save on an extra call to .copy(immutable=True) when the returned graph is needed to be immutable.

Alternatives Considered

N/A

Additional Information

No response

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 5, 2025
sagemathgh-39264: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 1)
    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 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.
- [x] 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#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 7, 2025
sagemathgh-39264: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 1)
    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 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.
- [x] 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#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 9, 2025
sagemathgh-39264: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 1)
    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 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.
- [x] 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#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 10, 2025
sagemathgh-39264: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 1)
    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 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.
- [x] 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#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 12, 2025
sagemathgh-39264: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 1)
    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 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.
- [x] 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#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 16, 2025
sagemathgh-39264: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 1)
    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 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.
- [x] 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#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 17, 2025
sagemathgh-39264: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 1)
    
We add parameter `immutable` to some generators in
`age/graphs/digraph_generators.py`.

This is straightforward for most of them, except for `RandomTournament`
where we use `getrandbits` rather than repeated calls to `random()`.
This is similar to what is done in method
`Graph(...).random_orientation()`.

This PR is motivated by discussions in sagemath#39177.

### 📝 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.
- [x] 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#39264
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 20, 2025
sagemathgh-39247: add parameter immutable to generators in `src/sage/graphs/graph_generators.py`
    
We add parameter `immutable` to all generators in
`src/sage/graphs/graph_generators.py`.

As suggested in sagemath#39177, all methods creating and returning a graph
should offer the option to get an immutable graph.


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39247
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 20, 2025
sagemathgh-39317: add parameter immutable to all methods in `sage/graphs/generators/basic.py`
    
Following discussions in sagemath#39177, we add parameter `immutable` to all
methods in `sage/graphs/generators/basic.py`.
We also add parameter `name` to some methods to ease constructions.

### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39317
Reported by: David Coudert
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 23, 2025
sagemathgh-39247: add parameter immutable to generators in `src/sage/graphs/graph_generators.py`
    
We add parameter `immutable` to all generators in
`src/sage/graphs/graph_generators.py`.

As suggested in sagemath#39177, all methods creating and returning a graph
should offer the option to get an immutable graph.


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39247
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 23, 2025
sagemathgh-39317: add parameter immutable to all methods in `sage/graphs/generators/basic.py`
    
Following discussions in sagemath#39177, we add parameter `immutable` to all
methods in `sage/graphs/generators/basic.py`.
We also add parameter `name` to some methods to ease constructions.

### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39317
Reported by: David Coudert
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 25, 2025
sagemathgh-39247: add parameter immutable to generators in `src/sage/graphs/graph_generators.py`
    
We add parameter `immutable` to all generators in
`src/sage/graphs/graph_generators.py`.

As suggested in sagemath#39177, all methods creating and returning a graph
should offer the option to get an immutable graph.


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39247
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 25, 2025
sagemathgh-39317: add parameter immutable to all methods in `sage/graphs/generators/basic.py`
    
Following discussions in sagemath#39177, we add parameter `immutable` to all
methods in `sage/graphs/generators/basic.py`.
We also add parameter `name` to some methods to ease constructions.

### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39317
Reported by: David Coudert
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 26, 2025
sagemathgh-39247: add parameter immutable to generators in `src/sage/graphs/graph_generators.py`
    
We add parameter `immutable` to all generators in
`src/sage/graphs/graph_generators.py`.

As suggested in sagemath#39177, all methods creating and returning a graph
should offer the option to get an immutable graph.


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39247
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 26, 2025
sagemathgh-39317: add parameter immutable to all methods in `sage/graphs/generators/basic.py`
    
Following discussions in sagemath#39177, we add parameter `immutable` to all
methods in `sage/graphs/generators/basic.py`.
We also add parameter `name` to some methods to ease constructions.

### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39317
Reported by: David Coudert
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 28, 2025
sagemathgh-39285: add parameter `immutable` to some graph products in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 29, 2025
sagemathgh-39285: add parameter `immutable` to some graph products in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 30, 2025
sagemathgh-39285: add parameter `immutable` to some graph products in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Jan 31, 2025
sagemathgh-39285: add parameter `immutable` to some graph products in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 3, 2025
sagemathgh-39285: add parameter `immutable` to some graph products in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 4, 2025
sagemathgh-39285: add parameter `immutable` to some graph products in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 9, 2025
sagemathgh-39280: add parameter `immutable` to some graph operations in `sage/graphs/generic_graph.py`
    
As proposed in sagemath#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

<!-- 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.
- [x] I have created tests covering the changes.
- [x] 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#39280
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 9, 2025
sagemathgh-39285: add parameter `immutable` to some graph products in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 9, 2025
sagemathgh-39280: add parameter `immutable` to some graph operations in `sage/graphs/generic_graph.py`
    
As proposed in sagemath#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

<!-- 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.
- [x] I have created tests covering the changes.
- [x] 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#39280
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 9, 2025
sagemathgh-39285: add parameter `immutable` to some graph products in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 10, 2025
sagemathgh-39280: add parameter `immutable` to some graph operations in `sage/graphs/generic_graph.py`
    
As proposed in sagemath#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

<!-- 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.
- [x] I have created tests covering the changes.
- [x] 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#39280
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 10, 2025
sagemathgh-39285: add parameter `immutable` to some graph products in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to some graph product operations defined in
`sage/graphs/generic_graph.py`:
- `cartesian_product`
- `tensor_product`
- `lexicographic_product`
- `strong_product`
- `disjunctive_product`


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39285
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 10, 2025
…hs/generic_graph.py`

    
Following sagemath#39280, sagemath#39285, sagemath#39287, sagemath#39296 and discussions in sagemath#39177, we
add parameter immutable to methods  in `sage/graphs/generic_graph.py`:
- `longest_cycle`
- `longest_path`
- `hamiltonian_path`
- and add tests in `cycle_basis`

### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39297
Reported by: David Coudert
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 18, 2025
sagemathgh-39266: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 2)
    
Following sagemath#39264, we add parameter immutable to `DeBruijn`,
`GeneralizedDeBruijn`, `Kautz` and `ImaseItoh`.

We also add parameter `name` to `GeneralizedDeBruijn` and `ImaseItoh` to
ease calls from `DeBruijn` and `Kautz`.

This PR is motivated by discussions in sagemath#39177.

### 📝 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#39266
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Feb 21, 2025
sagemathgh-39266: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 2)
    
Following sagemath#39264, we add parameter immutable to `DeBruijn`,
`GeneralizedDeBruijn`, `Kautz` and `ImaseItoh`.

We also add parameter `name` to `GeneralizedDeBruijn` and `ImaseItoh` to
ease calls from `DeBruijn` and `Kautz`.

This PR is motivated by discussions in sagemath#39177.

### 📝 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#39266
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Mar 1, 2025
sagemathgh-39269: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 3)
    
Following sagemath#39264 and sagemath#39266, we add parameter immutable to the remaining
digraph generators.

This PR is motivated by discussions in sagemath#39177.

### 📝 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#39269
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Mar 2, 2025
sagemathgh-39269: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 3)
    
Following sagemath#39264 and sagemath#39266, we add parameter immutable to the remaining
digraph generators.

This PR is motivated by discussions in sagemath#39177.

### 📝 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#39269
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Mar 3, 2025
sagemathgh-39269: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 3)
    
Following sagemath#39264 and sagemath#39266, we add parameter immutable to the remaining
digraph generators.

This PR is motivated by discussions in sagemath#39177.

### 📝 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#39269
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Mar 9, 2025
sagemathgh-39269: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 3)
    
Following sagemath#39264 and sagemath#39266, we add parameter immutable to the remaining
digraph generators.

This PR is motivated by discussions in sagemath#39177.

### 📝 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#39269
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Mar 9, 2025
sagemathgh-39287: add parameter `immutable` to transitive closure methods in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to methods related to transitive closure in
`sage/graphs/generic_graph.py` and `sage/graphs/generic_graph_pyx.pyx`:
- `transitive_closure`. We also fix the use of parameter `loops` that
was previously ignored
- `transitive_reduction`
- `transitive_reduction_acyclic`
- `is_transitively_reduced`. Here we ensure that the method accepts
immutable digraphs.


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39287
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Mar 9, 2025
sagemathgh-39269: add parameter immutable to generators in `sage/graphs/digraph_generators.py` (part 3)
    
Following sagemath#39264 and sagemath#39266, we add parameter immutable to the remaining
digraph generators.

This PR is motivated by discussions in sagemath#39177.

### 📝 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#39269
Reported by: David Coudert
Reviewer(s): David Coudert, Frédéric Chapoton
vbraun pushed a commit to vbraun/sage that referenced this issue Mar 9, 2025
sagemathgh-39287: add parameter `immutable` to transitive closure methods in `sage/graphs/generic_graph.py`
    
Following sagemath#39280 and discussions in sagemath#39177, we add parameter `immutable`
to methods related to transitive closure in
`sage/graphs/generic_graph.py` and `sage/graphs/generic_graph_pyx.pyx`:
- `transitive_closure`. We also fix the use of parameter `loops` that
was previously ignored
- `transitive_reduction`
- `transitive_reduction_acyclic`
- `is_transitively_reduced`. Here we ensure that the method accepts
immutable digraphs.


### 📝 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.
- [x] I have created tests covering the changes.
- [x] 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#39287
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants