Skip to content

Conversation

damianbasso
Copy link
Contributor

@damianbasso damianbasso commented Oct 30, 2023

Implemented graph generators which produce a random k-tree and a random partial k-tree. The k-tree algorithm first generates a complete graph, before adding vertices one by one, creating a clique utilising random existing vertices and the new vertex. Partial k-trees are generated by producing a k-tree and then randomly removing edges from it.

Previously SageMath lacked a way to generat randomised graphs which have a fixed treewidth value. This provides a methodology to do so .

Addresses #36586

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • 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 accordingly.

@dcoudert
Copy link
Contributor

For your information, there is an (old) open issue about generating k-trees #11369.

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.

Thank you for this contribution. Random k-trees are useful.

I have a few suggestions for improving the code.

@damianbasso
Copy link
Contributor Author

Thank you for this contribution. Random k-trees are useful.

I have a few suggestions for improving the code.

Thanks for reviewing @dcoudert. Just added another commit implementing your suggestions.

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.

a few more suggestions.

@damianbasso
Copy link
Contributor Author

a few more suggestions.

Thanks, some good ideas. I've added to the Pull Request

@damianbasso damianbasso requested a review from dcoudert November 9, 2023 03:19
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.

some details.

@damianbasso damianbasso requested a review from dcoudert November 11, 2023 09:39
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
Copy link
Member

vbraun commented Dec 3, 2023

[sagemath_doc_html-none] OSError: /home/release/Sage/src/sage/graphs/generators/random.py:docstring of sage.graphs.generators.random.RandomPartialKTree:11: WARNING: Bullet list ends without a blank line; unexpected unindent.

vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 24, 2023
sagemathgh-36924: add interface to nauty's genktreeg
    
Nauty has a generator of k-trees. We add an interface to this generator.
This is a complement of sagemath#36587.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [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 accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36924
Reported by: David Coudert
Reviewer(s): Matthias Köppe
vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 26, 2023
sagemathgh-36924: add interface to nauty's genktreeg
    
Nauty has a generator of k-trees. We add an interface to this generator.
This is a complement of sagemath#36587.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [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 accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36924
Reported by: David Coudert
Reviewer(s): Matthias Köppe
@dcoudert
Copy link
Contributor

dcoudert commented Feb 5, 2024

You should certainly rebase the branch on the last beta to launch all the tests.

@damianbasso damianbasso force-pushed the kTreeGenerators branch 2 times, most recently from e745c71 to 92d5967 Compare February 6, 2024 05:25
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.

Some improvements to ensure that the method cannot be called with wrong parameters.

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.

Copy link

Documentation preview for this PR (built with commit e7ed8e7; changes) is ready! 🎉

@dcoudert
Copy link
Contributor

I don't understand the last 2 commits. Is it due to the last beta release ?

You should certainly rebase the branch on the last beta.

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.

I have no more comments. Thanks.

LGTM.

vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 18, 2024
sagemathgh-36587: Created functions to generate random k-tree and partial k-tree graphs
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->
Implemented graph generators which produce a random k-tree and a random
partial k-tree. The k-tree algorithm first generates a complete graph,
before adding vertices one by one, creating a clique utilising random
existing vertices and the new vertex. Partial k-trees are generated by
producing a k-tree and then randomly removing edges from it.

<!-- Why is this change required? What problem does it solve? -->
Previously SageMath lacked a way to generat randomised graphs which have
a fixed treewidth value. This provides a methodology to do so .
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
Addresses sagemath#36586
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [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 accordingly.


<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36587
Reported by: Damian Basso
Reviewer(s): Damian Basso, David Coudert
vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 19, 2024
sagemathgh-36587: Created functions to generate random k-tree and partial k-tree graphs
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->
Implemented graph generators which produce a random k-tree and a random
partial k-tree. The k-tree algorithm first generates a complete graph,
before adding vertices one by one, creating a clique utilising random
existing vertices and the new vertex. Partial k-trees are generated by
producing a k-tree and then randomly removing edges from it.

<!-- Why is this change required? What problem does it solve? -->
Previously SageMath lacked a way to generat randomised graphs which have
a fixed treewidth value. This provides a methodology to do so .
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
Addresses sagemath#36586
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [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 accordingly.


<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36587
Reported by: Damian Basso
Reviewer(s): Damian Basso, David Coudert
@vbraun vbraun merged commit 34e5618 into sagemath:develop Feb 25, 2024
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.

4 participants