Esempio n. 1
0
def create_graph(n, nc, feature_dim, k, p, seed=100):
    """

    :param n: number of nodes
    :param nc: number of connected components
    :return: graph of networkx format
    """
    # np.random.seed(123)
    n_nodes = random_number_of_nodes(n, nc, k)
    graphs = []

    idx_node_large_graph = 0
    for n_node in n_nodes:
        graph, feature = FullySynthetic.generate_small_world_graph(
            None, n_node, k, p, feature_dim=feature_dim, seed=seed)
        add_feature_to_graph(graph, feature)
        print("====Subgraph===")
        print(nx.info(graph))
        to_one_connected_components(graph)
        graph, idx_node_large_graph = relabel_graph(graph,
                                                    idx_node_large_graph)
        graphs.append(graph)

    check_graphs_labels_distinguish(graphs)

    while len(graphs) > 1:
        graph = nx.compose(graphs[0], graphs[1])
        graphs = [graph, *graphs[2:]]
    print("====Large graph====")
    print(nx.info(graphs[0]))
    print("Number of connected components:",
          len(list(nx.connected_components(graphs[0]))))
    return graphs[0]
Esempio n. 2
0
from input.semi_synthetic import SemiSynthetic
from input.fully_synthetic import FullySynthetic
import numpy as np

n_nodes = [1000, 2000, 5000, 10000, 20000]
ks = [20,60,100,200,350]

for n in n_nodes:
    for k in ks:
        #np.random.seed(123)
        outdir="../dataspace/graph/fully-synthetic/small-world-n{}-k{}-p5-seed123/".format(n, k)
        FullySynthetic.generate_small_world_graph(outdir,n_nodes=n,k_neighbors=k, p_edge_modify=0.5, feature_dim=16)
        semiSynthetic = SemiSynthetic(outdir+'/graphsage',outdir+'/random-d01')
        semiSynthetic.generate_random_clone_synthetic(0, 0.01)
Esempio n. 3
0
def gen_fully_smallworld(full, n_nodes, p):
    name_p = str(int(p))
    outdir = full+"/small_world-n{}-p{}".format(n_nodes,name_p)
    FullySynthetic.generate_small_world_graph(outdir, n_nodes, int(p), 0.35)
    return outdir