def del_loop(ds, H, iter=0, verbose=True, capsize=1000): n = len(H) dsr = {} s = set() ss = set() print iter, for gnum in ds: gset = [] s = set() for sloop in ds[gnum]: rset = ds[gnum] - set([sloop]) num = reduce(operator.or_, rset) if not num in s: g = bfu.num2CG(num, n) if bfu.overshoot(g, H): s.add(num) gset.append((num,rset)) if gset == []: print '.', ss.add(gnum) for gn in gset: dsr[gn[0]] = gn[1] print '' return dsr, ss
def patchmerge(ds, H, cds): n = len(H) l = set() s = set() o = set() for gkey in ds: for num in ds[gkey]: if gkey & num: continue gnum = gkey | num if gnum is s: continue if skip_conflictors(gnum, cds): continue g = bfu.num2CG(gnum, n) if not bfu.call_u_conflicts(g, H): l.add(gnum) if bfu.call_u_equals(g, H): s.add(gnum) elif not gnum in o and bfu.overshoot(g, H): o.add(gnum) return l, s, o
def patchmerge(ds, H, cds): n = len(H) l = set() s = set() o = set() for gkey in ds: for num in ds[gkey]: if gkey & num: continue gnum = gkey | num if gnum is s: continue if skip_conflictors(gnum, cds): continue g = bfu.num2CG(gnum,n) if not bfu.call_u_conflicts(g, H): l.add(gnum) if bfu.call_u_equals(g, H): s.add(gnum) elif not gnum in o and bfu.overshoot(g, H): o.add(gnum) return l, s, o
def edgemask2(gl,H, cds): n = len(H) nl= len(gl) s = set() o = set() mask = np.zeros((nl,nl),'int') np.fill_diagonal(mask,-1) for i in xrange(nl): for j in xrange(i+1,nl): if gl[i] & gl[j]: continue gnum = gl[i] | gl[j] if skip_conflictors(gnum, cds): continue g = bfu.num2CG(gnum,n) if not bfu.call_u_conflicts(g, H): if bfu.call_u_equals(g, H): s.add(gnum) mask[i,j] = gnum mask[j,i] = gnum elif bfu.overshoot(g, H): o.add(gnum) return mask, s, o # mask, found eqc members, overshoots
def edgemask2(gl, H, cds): n = len(H) nl = len(gl) s = set() o = set() mask = np.zeros((nl, nl), 'int') np.fill_diagonal(mask, -1) for i in xrange(nl): for j in xrange(i + 1, nl): if gl[i] & gl[j]: continue gnum = gl[i] | gl[j] if skip_conflictors(gnum, cds): continue g = bfu.num2CG(gnum, n) if not bfu.call_u_conflicts(g, H): if bfu.call_u_equals(g, H): s.add(gnum) mask[i, j] = gnum mask[j, i] = gnum elif bfu.overshoot(g, H): o.add(gnum) return mask, s, o # mask, found eqc members, overshoots