Skip to content

Commit

Permalink
hpivot notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
akissinger committed Oct 9, 2019
1 parent 5d409a2 commit b2db1ab
Show file tree
Hide file tree
Showing 2 changed files with 295 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pyzx/hrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def match_hpivot(g, matchf=None):

types = g.types()
phases = g.phases()
m = []

min_degree = -1

for h in g.vertices():
if not (
Expand All @@ -77,11 +80,6 @@ def match_hpivot(g, matchf=None):

v0, v1 = g.neighbours(h)

if not (
types[v0] == 1 and phases[v0] == 0 and
types[v1] == 1 and phases[v1] == 0
): continue

v0n = set(g.neighbours(v0))
v1n = set(g.neighbours(v1))

Expand Down Expand Up @@ -119,8 +117,12 @@ def match_hpivot(g, matchf=None):
len(v1b) + len(v1h) + 1 == len(v1n)
): continue

return [(h, v0, v1, v0b, v1b, v0nn, v1nn)]
return []
degree = g.vertex_degree(v0) * g.vertex_degree(v1)

if min_degree == -1 or degree < min_degree:
m = [(h, v0, v1, v0b, v1b, v0nn, v1nn)]
min_degree = degree
return m


def hpivot(g, m):
Expand Down
Loading

0 comments on commit b2db1ab

Please sign in to comment.