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

Return connected subgraphs with exactly k vertices #35864

Merged
merged 3 commits into from
Jul 20, 2023

Conversation

deinst
Copy link
Contributor

@deinst deinst commented Jun 30, 2023

Fixes #35857 -- This PR adds a parameter to connected_subgraph_iterator so it returns only the subgraphs of order k.

  • Added an optional parameter 'exactly_k' to connected_subgraph_iterator
  • when exactly_k is True return only graphs of size k.
  • As the connected subgraphs are built up one vertex at a time (basically a DFS) we don't lose much if we are looking for subgraphs that are small in comparison to the original graph.

📚 Description

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

⌛ Dependencies

In response to issue sagemath#35857 modified connected_subgraph_iterator to just
return the subgraphs of order k.
- Added a parameter 'exactly_k
@@ -783,6 +784,10 @@ def connected_subgraph_iterator(G, k=None, bint vertices_only=False,
connected sub(di)graph only or also non-induced sub(di)graphs.
This parameter can be set to ``False`` for simple (di)graphs only.

- ``exactly_k`` -- boolean (default: ``False``); ``True`` if we only
return graphs of order ``k``, ``False`` if we return graphs of order
Copy link
Contributor

Choose a reason for hiding this comment

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

-      return graphs of order ``k``, ``False`` if we return graphs of order
-      at most ``k``.
+      return graphs of order `k`, ``False`` if we return graphs of order
+      at most `k`.

@dcoudert
Copy link
Contributor

Can you modify the PR description to link it to the issue. This way, when this PR will be closed, the issue will be closed as well.
You can change the fist sentence

In response to issue #35857 modified connected_subgraph_iterator to just return the subgraphs of order k.

to something like

Fixes #35857. This PR adds a parameter to connected_subgraph_iterator to just return the subgraphs of order k.

Thanks.

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.

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

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

@vbraun vbraun merged commit 0f23d09 into sagemath:develop Jul 20, 2023
@mkoeppe mkoeppe added this to the sage-10.1 milestone Jul 20, 2023
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.

add option to connected_subgraph_iterator to return subgraphs with exactly k vertices
5 participants