コード例 #1
0
def middleout_explore(G, alg, c, ignore=[]):

    # c: start as a single edge e.g. (0,1) and every recursion adds a
    # neighbour to it

    # Reaches the base case when the maximum size clique is found
    if len(c) == alg.max:
        return
    else:

        # Get all the connected neighbour vertex of the edge
        V = set(graph.neighborhood(c, G))
        for v in V:
            # If the edge c does not contain the vertex
            if v not in c:
                if canonical.canonical_r2(c, v, G, ignore=ignore):
                    c.append(v)
                    LOG.debug('%s %s' % (str(c), 'F'))

                    # Check if the neighor is connected to any sides of the edge
                    if alg.filter(c, G, v):

                        # For cliques, we find a n-d clique
                        alg.process(c, G)

                        # Keep going to find a larger clique
                        middleout_explore(G, alg, c, ignore=ignore)
                    c.pop()
                else:
                    LOG.debug('%s %s' % (str(c), 'R'))
コード例 #2
0
def backwards_explore(G, alg, c, last_v=None):
    if not canonical.canonical_r2_all(c, G):
        LOG.debug('%s %s' % (str(c), 'R2'))
        return
    elif not canonical.canonical_r1_all(c):
        LOG.debug('%s %s' % (str(c), 'R1'))
    else:
        LOG.debug('%s %s' % (str(c), 'F'))
        if alg.filter(c, G, last_v):
            alg.process(c, G)
        else:
            return

    if len(c) > alg.max:
        return
    else:
        V = set(
            filter(lambda v: last_v is None or True, graph.neighborhood(c, G)))
        for v in V:
            if v not in c:
                for i in range(0, len(c) + 1):
                    c.insert(i, v)
                    if graph.is_connected(v, c, G):
                        backwards_explore(G, alg, c, v)
                    c.pop(i)
コード例 #3
0
ファイル: mining.py プロジェクト: bindscha/tesseract-python
def forwards_explore(G, alg, c):
    if len(c) == alg.max:
        return
    else:
        V = set(graph.neighborhood(c, G))
        for v in V:
            if v not in c:
                if canonical.canonical(c, v, G):
                    c.append(v)
                    LOG.debug('%s %s' %(str(c), 'F'))
                    if alg.filter(c, G, v):
                        alg.process(c, G)
                        forwards_explore(G, alg, c)
                    c.pop()
                else:
                    LOG.debug('%s %s' %(str(c), 'R'))
コード例 #4
0
ファイル: mining.py プロジェクト: bindscha/tesseract-python
def middleout_explore(G, alg, c, ignore=[]):
    if len(c) == alg.max:
        return
    else:
        V = set(graph.neighborhood(c, G))
        for v in V:
            if v not in c:
                if canonical.canonical_r2(c, v, G, ignore=ignore):
                    c.append(v)
                    LOG.debug('%s %s' %(str(c), 'F'))
                    if alg.filter(c, G, v):
                        alg.process(c, G)
                        middleout_explore(G, alg, c, ignore=ignore)
                    c.pop()
                else:
                    LOG.debug('%s %s' %(str(c), 'R'))
コード例 #5
0
def canonicalize(e, G):
    if len(e) <= 1:
        return e
    else:
        e = sorted(e)
        e_c = [e[0]]
        e = e[1:]

        while len(e) > 0:
            V = graph.neighborhood(e_c, G)
            for i, u in enumerate(e):
                if u in V:
                    e_c.append(u)
                    e.pop(i)
                    break

        return e_c