Skip to content

quotient graph from the modular decomposition of a graph - #43053

Merged
vbraun merged 2 commits into
sagemath:developfrom
dcoudert:graphs/quotient_graph
Nov 8, 2026
Merged

vbraun merged 2 commits into
sagemath:developfrom
dcoudert:graphs/quotient_graph

Conversation

@dcoudert

Copy link
Copy Markdown
Collaborator

Add a method to compute the quotient graph $Q$ from the modular decomposition of a graph $G$. This graph has one vertex per module of the decomposition and edges according the rules of the modular decomposition.

sage: G = graphs.StarGraph(7)
sage: Q = G.quotient_graph()
sage: Q.order(), Q.size()
(2, 1)
sage: Q = G.quotient_graph(style='graph')
sage: from sage.graphs.graph_decompositions.modular_decomposition import graph_from_quotient
sage: H = graph_from_quotient(Q)
sage: H.is_isomorphic(G)
True
sage: G = graphs.RandomGNP(1000, 0.002)
sage: Q = G.quotient_graph(style='graph')
sage: H = graph_from_quotient(Q)
sage: H.is_isomorphic(G)
True
sage: G.order(), Q.order()
(1000, 194)

📝 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

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

@dcoudert

dcoudert commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 30, 2026
Release Manager
sagemathgh-43053: quotient graph from the modular decomposition of a graph
    
Add a method to compute the quotient graph $Q$ from the modular
decomposition of a graph $G$. This graph has one vertex per module of
the decomposition and edges according the rules of the modular
decomposition.

```sage
sage: G = graphs.StarGraph(7)
sage: Q = G.quotient_graph()
sage: Q.order(), Q.size()
(2, 1)
sage: Q = G.quotient_graph(style='graph')
sage: from sage.graphs.graph_decompositions.modular_decomposition import
graph_from_quotient
sage: H = graph_from_quotient(Q)
sage: H.is_isomorphic(G)
True
sage: G = graphs.RandomGNP(1000, 0.002)
sage: Q = G.quotient_graph(style='graph')
sage: H = graph_from_quotient(Q)
sage: H.is_isomorphic(G)
True
sage: G.order(), Q.order()
(1000, 194)
```

### 📝 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.
- [ ] 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#43053
Reported by: David Coudert
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 30, 2026
Release Manager
sagemathgh-43080: Fix CategoryObject type-only import lint failure
    
The lint job on sagemath#43053 fails with Ruff TC001 because `CategoryObject` is
imported only for the annotation of `R` in
`src/sage/tests/type_checking/structure_returns.py`. The same failure is
present on `develop`, so other PRs inherit it too.

Move the import into `if TYPE_CHECKING:` and enable postponed
annotations, following the adjacent type-checking modules. The return-
type assertions remain unchanged.

Validation: reproduced TC001 before the fix; both complete repository
Ruff passes using `.github/workflows/ruff.toml` (`--no-preview` and
`--preview`) pass afterward. `git diff --check` also passes.

Failing job: https://github.com/sagemath/sage/actions/runs/40855714538/j
ob/123386034361
    
URL: sagemath#43080
Reported by: Dima Pasechnik
Reviewer(s): David Coudert
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 31, 2026
Release Manager
sagemathgh-43053: quotient graph from the modular decomposition of a graph
    
Add a method to compute the quotient graph $Q$ from the modular
decomposition of a graph $G$. This graph has one vertex per module of
the decomposition and edges according the rules of the modular
decomposition.

```sage
sage: G = graphs.StarGraph(7)
sage: Q = G.quotient_graph()
sage: Q.order(), Q.size()
(2, 1)
sage: Q = G.quotient_graph(style='graph')
sage: from sage.graphs.graph_decompositions.modular_decomposition import
graph_from_quotient
sage: H = graph_from_quotient(Q)
sage: H.is_isomorphic(G)
True
sage: G = graphs.RandomGNP(1000, 0.002)
sage: Q = G.quotient_graph(style='graph')
sage: H = graph_from_quotient(Q)
sage: H.is_isomorphic(G)
True
sage: G.order(), Q.order()
(1000, 194)
```

### 📝 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.
- [ ] 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#43053
Reported by: David Coudert
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 31, 2026
Release Manager
sagemathgh-43080: Fix CategoryObject type-only import lint failure
    
The lint job on sagemath#43053 fails with Ruff TC001 because `CategoryObject` is
imported only for the annotation of `R` in
`src/sage/tests/type_checking/structure_returns.py`. The same failure is
present on `develop`, so other PRs inherit it too.

Move the import into `if TYPE_CHECKING:` and enable postponed
annotations, following the adjacent type-checking modules. The return-
type assertions remain unchanged.

Validation: reproduced TC001 before the fix; both complete repository
Ruff passes using `.github/workflows/ruff.toml` (`--no-preview` and
`--preview`) pass afterward. `git diff --check` also passes.

Failing job: https://github.com/sagemath/sage/actions/runs/40855714538/j
ob/123386034361
    
URL: sagemath#43080
Reported by: Dima Pasechnik
Reviewer(s): David Coudert
vbraun pushed a commit to vbraun/sage that referenced this pull request Nov 7, 2026
Release Manager
sagemathgh-43080: Fix CategoryObject type-only import lint failure
    
The lint job on sagemath#43053 fails with Ruff TC001 because `CategoryObject` is
imported only for the annotation of `R` in
`src/sage/tests/type_checking/structure_returns.py`. The same failure is
present on `develop`, so other PRs inherit it too.

Move the import into `if TYPE_CHECKING:` and enable postponed
annotations, following the adjacent type-checking modules. The return-
type assertions remain unchanged.

Validation: reproduced TC001 before the fix; both complete repository
Ruff passes using `.github/workflows/ruff.toml` (`--no-preview` and
`--preview`) pass afterward. `git diff --check` also passes.

Failing job: https://github.com/sagemath/sage/actions/runs/40855714538/j
ob/123386034361
    
URL: sagemath#43080
Reported by: Dima Pasechnik
Reviewer(s): David Coudert
vbraun pushed a commit to vbraun/sage that referenced this pull request Nov 7, 2026
Release Manager
sagemathgh-43090: add method to compute the modular-width of a graph
    
Now that we can compute the modular decomposition of a graph, we can
compute its modular-width.


### 📝 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

sagemath#43053 - mostly to avoid merge conflicts
    
URL: sagemath#43090
Reported by: David Coudert
Reviewer(s): Martin Rubey
@vbraun
vbraun merged commit 106a49d into sagemath:develop Nov 8, 2026
21 of 23 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.

2 participants