-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: Add SiblingSubgraph::from_node
#1655
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1655 +/- ##
=======================================
Coverage 85.51% 85.52%
=======================================
Files 136 136
Lines 25264 25293 +29
Branches 22176 22205 +29
=======================================
+ Hits 21605 21632 +27
- Misses 2455 2456 +1
- Partials 1204 1205 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better commit message here is feat: Add SiblingSubgraph::from_node
.
let checker = TopoConvexChecker::new(hugr); | ||
Self::try_from_nodes_with_checker(nodes, hugr, &checker) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change doesn't seem necessary. try_from_nodes_with_checker
already does this, and TopoConvexChecker::new
is cheap now.
Co-authored-by: Douglas Wilson <141026920+doug-q@users.noreply.github.com>
SiblingSubgraph::try_from_nodes
when n=1
SiblingSubgraph::from_node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
Complementary improvement to #1654.
Creating a k-node subgraph in an n-node graph should ideally be
O(k)
.However, due to CQCL/portgraph#155 this ends up being
O(n)
.For
k=1
, this results in a linear cost overhead.This PR adds a special case (written by @doug-q) that completely skips the unnecessary checks.