Example #1
0
def ecmerge(H):
    """Find all graphs in the same equivalence class with respect to H

    Arguments:
    - `H`: an undersampled graph
    """
    if cmp.isSclique(H):
        print 'not running on superclique'
        return None
    n = len(H)
    s = set()
    ds = confpairs(H)
    ccf = conflictors(H)
    cset = set()
    for e in ccf:
        cset = cset.union(ccf[e])

    glist = np.r_[[0], 2**np.arange(n**2)]
    #glist =  2**np.arange(n**2)

    #glist, ss = quadmerge(glist,H)

    for i in range(int(2 * np.log2(n))):
        print i, len(glist)
        glist, ss = quadmerge_(glist, H, cset)
        s = s | ss
    return s
Example #2
0
def iteqclass(H, verbose=True, capsize=100):
    '''
    Find all graphs in the same equivalence class with respect to
    graph H and any undesampling rate.
    '''
    if cmp.isSclique(H):
        print 'not running on superclique'
        return None
    g = {n: {} for n in H}
    s = set()
    Hnum = bfu.ug2num(H)
    if Hnum[1] == 0: s.add(Hnum[0])

    cp = confpairs(H)
    ccf = conflictors(H)

    edges = gk.edgelist(gk.complement(g))
    ds = {bfu.g2num(g): edges}

    if verbose: print '%3s' % 'i' + '%10s' % ' graphs'
    for i in range(len(H)**2):
        ds, ss = add2set_(ds,
                          H,
                          cp,
                          ccf,
                          iter=i,
                          verbose=verbose,
                          capsize=capsize)
        s = s | ss
        if capsize <= len(ss): break
        if not ds: break

    return s
Example #3
0
def ldceqclass(H,asl=None):
    """Find all graphs in the same equivalence class with respect to H

    Arguments:
    - `H`: an undersampled graph
    """
    if cmp.isSclique(H):
        print 'not running on superclique'
        return set()
    n = len(H)
    s = set()
    cds = lconfpairs(H)
    if asl:
        sloops = asl
    else:
        sloops = prune_loops(allsloops(len(H)),H)

    glist =  sloops
    i = 1
    while glist != []:
        print i, len(glist)
        glist, ss = lquadmerge(glist, H, cds)
        s = s|ss
        i += 1
    return s
Example #4
0
def ecmerge(H):
    """Find all graphs in the same equivalence class with respect to H

    Arguments:
    - `H`: an undersampled graph
    """
    if cmp.isSclique(H):
        print 'not running on superclique'
        return None
    n = len(H)
    s = set()
    ds = confpairs(H)
    ccf = conflictors(H)
    cset = set()
    for e in ccf:
        cset = cset.union(ccf[e])

    glist =  np.r_[[0],2**np.arange(n**2)]
    #glist =  2**np.arange(n**2)

    #glist, ss = quadmerge(glist,H)

    for i in range(int(2*np.log2(n))):
        print i, len(glist)
        glist, ss = quadmerge_(glist,H, cset)
        s = s | ss
    return s
Example #5
0
def liteqclass(H, verbose=True, capsize=100, asl=None):
    '''
    Find all graphs in the same equivalence class with respect to
    graph H and any undesampling rate.
    '''
    if cmp.isSclique(H):
        print 'not running on superclique'
        return set([-1])
    g = {n:{} for n in H}
    s = set()



    if asl:
        sloops = asl
    else:
        sloops = prune_loops(allsloops(len(H)),H)

    cp  = []#lconfpairs(H, sloops=sloops)
    ccf = lconflictors(H, sloops=sloops)
    ds = {0: sloops}

    if verbose: print '%3s'%'i'+'%10s'%' graphs'
    i=0
    while ds:
        ds, ss = add2set_loop(ds, H, cp, ccf, iter=i,
                              verbose=verbose,
                              capsize=capsize,
                              currsize=len(s))
        s = s | ss
        i += 1
        if capsize <= len(s): break

    return s
Example #6
0
def iteqclass(H, verbose=True, capsize=100):
    '''
    Find all graphs in the same equivalence class with respect to
    graph H and any undesampling rate.
    '''
    if cmp.isSclique(H):
        print 'not running on superclique'
        return None
    g = {n:{} for n in H}
    s = set()
    Hnum = bfu.ug2num(H)
    if Hnum[1]==0: s.add(Hnum[0])

    cp = confpairs(H)
    ccf = conflictors(H)

    edges = gk.edgelist(gk.complement(g))
    ds = {bfu.g2num(g): edges}

    if verbose: print '%3s'%'i'+'%10s'%' graphs'
    for i in range(len(H)**2):
        ds, ss = add2set_(ds, H, cp, ccf, iter=i,
                            verbose=verbose,
                            capsize=capsize)
        s = s | ss
        if capsize <= len(ss): break
        if not ds: break

    return s
Example #7
0
def overshoot(G_star, H):
    glist = [G_star]
    while True:
        g = increment_u(G_star, glist[-1])
        if isSclique(g): return False
        if gk.isedgesubset(H, g): return True
        if g in glist: return False
        glist.append(g)
    return False
Example #8
0
def overshoot(G_star, H):
    glist = [G_star]
    while True:
        g = increment_u(G_star, glist[-1])
        if isSclique(g): return False
        if gk.isedgesubset(H, g): return True
        if g in glist: return False
        glist.append(g)
    return False
Example #9
0
def dceqclass2(H):
    """Find all graphs in the same equivalence class with respect to H

    Arguments:
    - `H`: an undersampled graph
    """
    if cmp.isSclique(H):
        print 'not running on superclique'
        return set()
    n = len(H)
    s = set()
    cp = confpairs(H)
    confs = conflictor_set(H)
    ccf = conflictors(H)

    def prune_loops(gl, H):
        l = []
        for e in gl:
            if e[0] == e[1] and not (e[1] in H[e[0]] and
                                     (1, 0) in H[e[0]][e[1]]):
                continue
            l.append(e)
        return l

    edges = gk.edgelist(gk.complement(bfu.num2CG(0, n)))
    edges = prune_loops(edges, H)
    glist = map(lambda x: e2num(x, n), edges)

    #glist =  list(2**np.arange(n**2))
    i = 0
    while glist != []:
        print 2**i, len(glist)
        glist_prev = glist
        glist, ss = quadmerge21(glist, H, confs)
        s = s | ss
        i += 1

    ds = {x: edges for x in glist_prev}

    for j in range(i, len(H)**2):
        ds, ss = add2set_(ds, H, cp, ccf, iter=j, verbose=True)
        s = s | ss
        if not ds: break

    return s
Example #10
0
def dceqclass2(H):
    """Find all graphs in the same equivalence class with respect to H

    Arguments:
    - `H`: an undersampled graph
    """
    if cmp.isSclique(H):
        print 'not running on superclique'
        return set()
    n = len(H)
    s = set()
    cp = confpairs(H)
    confs = conflictor_set(H)
    ccf = conflictors(H)

    def prune_loops(gl, H):
        l = []
        for e in gl:
            if e[0] == e[1] and not (e[1] in H[e[0]] and (1,0) in H[e[0]][e[1]]): continue
            l.append(e)
        return l
    edges = gk.edgelist(gk.complement(bfu.num2CG(0,n)))
    edges = prune_loops(edges, H)
    glist = map(lambda x: e2num(x,n),edges)

    #glist =  list(2**np.arange(n**2))
    i = 0
    while glist != []:
        print 2**i, len(glist)
        glist_prev = glist
        glist, ss = quadmerge21(glist, H, confs)
        s = s|ss
        i += 1


    ds = {x: edges for x in glist_prev}

    for j in range(i, len(H)**2):
        ds, ss = add2set_(ds, H, cp, ccf, iter=j, verbose=True)
        s = s | ss
        if not ds: break

    return s
Example #11
0
def dceqclass(H):
    """Find all graphs in the same equivalence class with respect to H

    Arguments:
    - `H`: an undersampled graph
    """
    if cmp.isSclique(H):
        print 'not running on superclique'
        return set()
    n = len(H)
    s = set()
    cds = confpairs(H)

    glist = [0] + list(2**np.arange(n**2))
    i = 1
    while glist != []:
        print i, len(glist)
        glist, ss = quadmerge(glist, H, cds)
        s = s | ss
        i += 1
    return s
Example #12
0
def dceqclass(H):
    """Find all graphs in the same equivalence class with respect to H

    Arguments:
    - `H`: an undersampled graph
    """
    if cmp.isSclique(H):
        print 'not running on superclique'
        return set()
    n = len(H)
    s = set()
    cds = confpairs(H)

    glist =  [0]+list(2**np.arange(n**2))
    i = 1
    while glist != []:
        print i, len(glist)
        glist, ss = quadmerge(glist, H, cds)
        s = s|ss
        i += 1
    return s
Example #13
0
def dceqc(H):
    """Find all graphs in the same equivalence class with respect to H

    Arguments:
    - `H`: an undersampled graph
    """
    if cmp.isSclique(H):
        print 'not running on superclique'
        return set()
    n = len(H)
    s = set()
    cds = confpairs(H)

    glist = [2**np.arange(n**2)]
    i = 1
    #for i in range(int(np.log2(n**2))):
    while glist != []:
        print i, np.max(map(len, glist)), len(glist)
        glist, ss = quadlister(glist, H, cds)
        s = s | ss
        i += 1
    return s
Example #14
0
def dceqc(H):
    """Find all graphs in the same equivalence class with respect to H

    Arguments:
    - `H`: an undersampled graph
    """
    if cmp.isSclique(H):
        print 'not running on superclique'
        return set()
    n = len(H)
    s = set()
    cds = confpairs(H)

    glist =  [2**np.arange(n**2)]
    i = 1
    #for i in range(int(np.log2(n**2))):
    while glist != []:
        print i, np.max(map(len,glist)), len(glist)
        glist, ss = quadlister(glist, H, cds)
        s = s|ss
        i += 1
    return s