Ejemplo n.º 1
0
    print()
    print()
    print("---ALIGNMENT---------")
    print()
    print("*NODES (ID, LABEL, NEIGHBOURS")
    for node in graph.nodes:
        print("{}".format(node))
    print()
    print("*EDGES (ID, LABEL)")
    for edge in graph.edges:
        print("{}".format(edge))
    print()
    print()
    print("---NEWICK TREE-------")
    print()
    print(graph.id)
    print()


if __name__ == '__main__':

    g_list = []

    for arg in sys.argv[1:]:
        g = parse_graph(arg)
        g_list.append(g)

    #print(g_list)
    res = upgma(g_list)
    print(res)
Ejemplo n.º 2
0
            # intersection of x respectively p and neighbours of v
            x_ = x & v.neighbours
            p_ = [n for n in v.neighbours if n in p]

            bk(r_, p_, x_)  # recursive call of broknkerbosch

            p.remove(v)  # taking current node out of canditates
            x.add(v)  # adding current node to garbage collection


# EXECUTION (PIVOT VERSION) ----------------------------------------------------

if __name__ == '__main__':

    try:

        bk = BK()
        graph = parse_graph(sys.argv[1])
        r = set()
        x = set()
        p = list(graph.nodes)
        bk.bk_pivot(r, p, x)
        pprint.pprint(bk.results)

    except Exception as e:
        print(e)
        print(
            ' please provide a graph file as argument \n example: python3 bk_pivot.py graph.graph'
        )
Ejemplo n.º 3
0
        '''
        computes current state of mapping by adding the last feasable nodes to
        the cores
        '''
        self.core_l_g[ tupel[0] ] = tupel[1]
        self.core_s_g[ tupel[1] ] = tupel[0]

    def restore_ds( self, n, m, depth ):

        self.restore_terminals(self.t_in_l, "in_l", self.core_l_g, depth)
        self.restore_terminals(self.t_out_l, "out_l", self.core_l_g, depth)
        self.restore_terminals(self.t_in_s, "in_s", self.core_s_g, depth)
        self.restore_terminals(self.t_out_s, "out_s", self.core_s_g, depth)

        self.core_l_g[n] = self.null_n
        self.core_s_g[m] = self.null_n

    def restore_terminals(self, t_dict, dict_key, core, depth):

        for node in t_dict:
            if core[node] == self.null_n and t_dict[node] == depth:
                t_dict[node] = 0


if __name__ == "__main__":

    g = parse_graph( sys.argv[1] )
    h = parse_graph( sys.argv[2] )
    vf2 = VfTwo( g, h )
    vf2.match()
Ejemplo n.º 4
0
        # determine if to look for subgraph isomorphism or graph isomorphism
        self.type = 'subgraph'
        if h.size == g.size:
            self.type = 'isomorphism'

        # make sure that edges are labelled
        if not small_g.is_directed:
            small_g.create_fake_directions()
        if not g2.is_directed:
            small_g.create_fake_directions()
        ''' initialiazing the two core dictionaries that store each node of the
        corresponding graph as key and the node of the other graph where it maps
        as soon as it mapps for now we use self.null_node as inital value'''
        core_small_g = dict.fromkeys(small_g.nodes, self.null_node)
        core_large_g = dict.fromkeys(large_g.nodes, self.null_node)
        ''' initialiazing the terminal sets for each graph. These are dictionaries
        that store the node as values and the recursion depth as keys where the
        nodes entered the corresponding set. For now we initialiazing them with 0 '''

        t_in_small = t_out_small = dict.fromkeys(small_g.nodes, 0)
        t_in_large = t_out_large = dict.fromkeys(large_g.nodes, 0)


if __name__ == "__main__":
    from parser import parse_graph

    g1 = parse_graph(sys.argv[1])
    g2 = parse_graph(sys.argv[2])
    vf = V(g1, g2)
    print(vf.typeS)