From aefaf546d85a8ccf698da27c13899635f681e711 Mon Sep 17 00:00:00 2001 From: Razin Shaikh Date: Fri, 2 Aug 2024 10:16:35 +0100 Subject: [PATCH] check_fuse_w: check if the vertices are connected before asking for its edge type --- pyzx/basicrules.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyzx/basicrules.py b/pyzx/basicrules.py index 579c1e54..193687d3 100644 --- a/pyzx/basicrules.py +++ b/pyzx/basicrules.py @@ -203,8 +203,8 @@ def check_fuse_w(g: BaseGraph[VT,ET], v1: VT, v2: VT) -> bool: if vertex_is_w(g.type(v1)) and vertex_is_w(g.type(v2)): v1_in, v1_out = get_w_io(g, v1) v2_in, v2_out = get_w_io(g, v2) - if g.edge_type(g.edge(v1_in, v2_out)) == EdgeType.SIMPLE or \ - g.edge_type(g.edge(v2_in, v1_out)) == EdgeType.SIMPLE: + if (g.connected(v1_in, v2_out) and g.edge_type(g.edge(v1_in, v2_out)) == EdgeType.SIMPLE) or \ + (g.connected(v2_in, v1_out) and g.edge_type(g.edge(v2_in, v1_out)) == EdgeType.SIMPLE): return True return False