Example #1
0
def algorithm_dpa(nodes_n, nodes_m):
    graph_V = er.algorithm_er(nodes_m, 1.0)
    print "Complete graph", graph_V
    for node_i in range(nodes_m, nodes_n):
        in_degree_graph = er.compute_in_degrees(graph_V)
        print in_degree_graph
        in_degree_sum = 0
        for key in in_degree_graph:
            in_degree_sum += in_degree_graph[key]
            print "In-degree sum is", in_degree_sum
        V_ = []
        while len(V_) < nodes_m:
            rnd_node = random.choice(graph_V.keys())
            probablity = float(in_degree_graph[rnd_node] + 1.0) / (in_degree_sum + len(graph_V))
            print "probablity", probablity
            a = random.uniform(0.0, 1.0)
            if a > probablity:
                if not rnd_node in V_:
                    V_.append(rnd_node)
        graph_V.update({node_i: set([])})
        print "V_ is", V_
        for v in V_:
            graph_V[node_i].add(v)
    return graph_V
Example #2
0
def algorithm_dpa(nodes_n,nodes_m):
    graph_V=er.algorithm_er(nodes_m,1.0)
    dpa_object=DPATrial(len(graph_V))
    for node_i in range(nodes_m,nodes_n):
        #in_degree_graph=er.compute_in_degrees(graph_V)
        V_=dpa_object.run_trial(nodes_m)
        graph_V.update({node_i:set([])})
        print "V_",V_
        for v in V_:
            graph_V[node_i].add(v)
    return graph_V
                
        
        

#print "The returned graph is",algorithm_dpa(27770,13)