Newer
Older
import networkx as nx
import argparse
import numpy as np
import pandas as pd
import random
import copy
from tqdm import tqdm
# COMMAND PARSING
parser = argparse.ArgumentParser()
parser.add_argument("output_dir")
args = parser.parse_args()
raise FileExistsError("Output directory does not exists !")
"stochastic_block_model_graph": {
"nb_nodes":GRAPH_SIZE,
"nb_edges":EDGE_SIZE,
"nb_com" :[2,5],
"percentage_edge_betw":[0.1,0.01]
Fize Jacques
committed
"powerlaw_graph": { # configuration_model
"nb_nodes":[100,150],
"coords":["random","country"],
}
#getattr(nx,"geographical_threshold_graph")(**dict(n=20,theta=0.4))
def get_params(inp):
return (dict(zip(inp.keys(), values)) for values in itertools.product(*inp.values()))
pbar = tqdm(parameters.items(),total=len(parameters))
for method,args in pbar:
pbar.set_description("Generating graphs using : " + method)
list_of_params = get_params(parameters[method])
for ix,params in enumerate(list_of_params):
# try:
G.graph.update(params)
nx.write_gml(G, OUTPUT_DIR+"/graph_{method}_{ix}.gml".format(method=method,ix=ix),stringizer=str)
# except Exception as e:
# print(e)