feat!: Add ResourceScope::is_convex #1057
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'll put this as draft for the time being, given that it is already stacked on top of other two PRs.
Does what the title says: using
ResourceScope's resource path tracking, we can check convexity of subcircuits very efficiently. Heavily inspired by portgraph'sLineConvexChecker, see Quantinuum/portgraph#240.Note that to be able to implement the convexity check, I changed
Positionfrom being a port property (i.e. each resource had its own position), to being a node-wide property. See the first of the two commits in this PR.As is, the conversion
Subcircuit->SiblingSubgraphis correct but unnecessarily slow: at construction time, hugr will check convexity of the subgraph again. My plan is to open a PR in hugr that allows us to bypass convexity checks and use that here in place ofSiblingSubgraph::try_new.