Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
SiblingSubgraph::from_node
(#1655)
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. ``` group before from_node ----- ------ --------- multinode_subgraph/10 1.01 17.7±0.26µs ? ?/sec 1.00 17.5±0.23µs ? ?/sec multinode_subgraph/100 1.00 169.1±11.34µs ? ?/sec 1.00 168.8±4.37µs ? ?/sec multinode_subgraph/1000 1.01 2.3±0.46ms ? ?/sec 1.00 2.3±0.34ms ? ?/sec singleton_subgraph/10 12.26 3.0±0.06µs ? ?/sec 1.00 245.6±21.24ns ? ?/sec singleton_subgraph/100 20.01 4.7±0.06µs ? ?/sec 1.00 234.4±6.50ns ? ?/sec singleton_subgraph/1000 93.34 22.0±0.25µs ? ?/sec 1.00 235.6±4.93ns ? ?/sec ``` --------- Co-authored-by: Douglas Wilson <141026920+doug-q@users.noreply.github.com>
- Loading branch information