コード例 #1
0
ファイル: graph.py プロジェクト: keiohigh2nd/hcc_1937
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
ファイル: graph.py プロジェクト: kekeke29341/hcc_1937
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
ファイル: graph.py プロジェクト: keiohigh2nd/hcc_1937
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
ファイル: graph.py プロジェクト: kekeke29341/hcc_1937
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
ファイル: graph.py プロジェクト: keiohigh2nd/hcc_1937
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
ファイル: graph.py プロジェクト: keiohigh2nd/hcc_1937
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
ファイル: graph.py プロジェクト: kekeke29341/hcc_1937
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
ファイル: graph.py プロジェクト: kekeke29341/hcc_1937
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)