Пример #1
0
def merge_graph_by_rank(G, G1, G2, frequency):
    #HCC is 0.9, Luc is 0.1 make sure
    n1 = G1.number_of_edges()
    n2 = G2.number_of_edges()

    e1 = G1.edges()
    e2 = G2.edges()

    for i in range(int(n1*frequency[0])):
      tmp = random.randint(0,n1-1)
      G.add_edge(e1[tmp][0], e1[tmp][1])

    target_nodes = calc.find_max_nodes(G2)
    print 'Top nodes'
    print target_nodes 

    for i in range(int(n2*frequency[1])):
      tmp = random.randint(0,n2-1)
      #Top target
      random_tmp = random.choice(target_nodes) 
      #Target of top targets
      random_tmp_target = random.choice(G2.neighbors(random_tmp[0]))
      G.add_edge(random_tmp[0], random_tmp_target)

    return G
Пример #2
0
def merge_graph_by_rank(G, G1, G2, frequency):
    #HCC is 0.9, Luc is 0.1 make sure
    n1 = G1.number_of_edges()
    n2 = G2.number_of_edges()

    e1 = G1.edges()
    e2 = G2.edges()

    for i in range(int(n1 * frequency[0])):
        tmp = random.randint(0, n1 - 1)
        G.add_edge(e1[tmp][0], e1[tmp][1])

    target_nodes = calc.find_max_nodes(G2)
    print 'Top nodes'
    print target_nodes

    for i in range(int(n2 * frequency[1])):
        tmp = random.randint(0, n2 - 1)
        #Top target
        random_tmp = random.choice(target_nodes)
        #Target of top targets
        random_tmp_target = random.choice(G2.neighbors(random_tmp[0]))
        G.add_edge(random_tmp[0], random_tmp_target)

    return G
Пример #3
0
def cut_graph(G):
    target_nodes = calc.find_max_nodes(G)
    for t in target_nodes:
      t_edges = G.neighbors(t[0])
      for t_e in t_edges:
        G.remove_edge(t[0], t_e)
      G.remove_node(t[0])
    return G
Пример #4
0
def cut_graph(G):
    target_nodes = calc.find_max_nodes(G)
    for t in target_nodes:
        t_edges = G.neighbors(t[0])
        for t_e in t_edges:
            G.remove_edge(t[0], t_e)
        G.remove_node(t[0])
    return G
Пример #5
0
def update_graph(G, gro):
    target_nodes = calc.find_max_nodes(G)
    #return calc.add_edges(G, target_nodes, gro)
    return calc.add_random_edges(G, target_nodes, gro)
Пример #6
0
def update_graph_mix_new(G, gro, mix_new):
    target_nodes = calc.find_max_nodes(G)
    return calc.add_random_edges_nodes(G, target_nodes, gro, mix_new)
Пример #7
0
def update_graph_mix_new(G, gro, mix_new):
    target_nodes = calc.find_max_nodes(G)
    return calc.add_random_edges_nodes(G, target_nodes, gro, mix_new)
Пример #8
0
def update_graph(G, gro):
    target_nodes = calc.find_max_nodes(G)
    #return calc.add_edges(G, target_nodes, gro)
    return calc.add_random_edges(G, target_nodes, gro)