Skip to content

Commit

Permalink
Update hugr-core/src/hugr/views/sibling_subgraph.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Douglas Wilson <[email protected]>
  • Loading branch information
aborgna-q and doug-q authored Nov 14, 2024
1 parent cab1550 commit e057877
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions hugr-core/src/hugr/views/sibling_subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,19 @@ impl SiblingSubgraph {
///
/// The subgraph signature will be given by signature of the node.
pub fn from_node(node: Node, hugr: &impl HugrView) -> Self {
// TODO once https://github.com/CQCL/portgraph/issues/155
// is fixed we can just call try_from_nodes here.
// Until then, doing this saves a lot of work.
let nodes = vec![node];
let inputs = hugr.all_linked_inputs(node).map(|x| vec![x]).collect_vec();
let outputs = hugr.all_linked_outputs(node).collect_vec();
let inputs = hugr
.node_inputs(node)
.filter_map(|p| hugr.is_linked(node, p).then(|| vec![(node, p)]))
.collect_vec();
let outputs = hugr
.node_outputs(node)
.filter_map(|p| hugr.is_linked(node, p).then_some((node, p)))
.collect_vec();

Self {
nodes,
inputs,
Expand Down

0 comments on commit e057877

Please sign in to comment.