Skip to content

Commit 20081dd

Browse files
lmondadamark-koch
andauthored
feat!: Accept outgoing ports in SimpleReplacement nu_out (#2151)
Currently, SimpleReplacement stores its output boundary map nu_out by referring to nodes outside the deleted subgraph in the host graph. This forces the invalidation set of the replacements to include nodes past the output, forbidding simultaneous adjacent replacements. This PR fixes this by allowing the keys of `nu_out` (i.e. the ports on the output boundary of the subgraph) to be either incoming ports (as before), or outgoing ports (in which case this is equivalent to specifying the map on all incoming ports linked to the given outgoing ports). The latter is less general but covers most use cases and reduces the size of the invalidation set. Closes #2098 BREAKING CHANGE: Generalised arguments to [`SimpleReplacement::new`] and [`SimpleReplacement::map_host_output`] to allow for outgoing ports. Previous type signatures remain valid, however, type inference may fail. --------- Co-authored-by: Mark Koch <[email protected]>
1 parent a918853 commit 20081dd

File tree

3 files changed

+291
-45
lines changed

3 files changed

+291
-45
lines changed

hugr-core/src/hugr/patch/port_types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub enum BoundaryPort<HostNode, P> {
2323
pub struct HostPort<N, P>(pub N, pub P);
2424

2525
/// A port in the replacement graph.
26-
#[derive(Debug, Clone, Copy, From)]
26+
#[derive(Debug, Clone, Copy, From, PartialEq, Eq, PartialOrd, Ord)]
2727
pub struct ReplacementPort<P>(pub Node, pub P);
2828

2929
impl<HostNode: Copy, P> BoundaryPort<HostNode, P> {

0 commit comments

Comments
 (0)