Skip to content
Snippets Groups Projects
Commit e0fab819 authored by Fize Jacques's avatar Fize Jacques
Browse files

Debug

parent 0ccb0c49
No related branches found
No related tags found
No related merge requests found
......@@ -59,8 +59,8 @@ methods = ['random_prediction',
"preferential_attachment",
"resource_allocation_index",
"stochastic_block_model",
"stochastic_block_model_edge_probs",
"stochastic_block_model_degree_corrected"
"stochastic_block_model_degree_corrected",
"spatial_link_prediction"
]
# Evaluate baselines
......
......@@ -17,8 +17,9 @@ parser.add_argument("output_dir")
args = parser.parse_args()
GRAPH_SIZE = [100,150,200]
EDGE_SIZE = [300,500]
GRAPH_SIZE = [80,800]
EDGE_SIZE = [2,3]
OUTPUT_DIR = args.output_dir
if not os.path.exists(OUTPUT_DIR):
raise FileExistsError("Output directory does not exists !")
......@@ -28,7 +29,7 @@ parameters = {
"stochastic_block_model_graph": {
"nb_nodes":GRAPH_SIZE,
"nb_edges":EDGE_SIZE,
"nb_com" :[2,5],
"nb_com" :[2,5,8,16],
"percentage_edge_betw":[0.1,0.01]
},
"ER_graph": {
......@@ -38,10 +39,11 @@ parameters = {
"powerlaw_graph": { # configuration_model
"nb_nodes":GRAPH_SIZE,
"nb_edges":EDGE_SIZE,
"exponent":[2,3]
"exponent":[2,3],
"tries":[100]
},
"spatial_graph":{
"nb_nodes":[100,150],
"nb_nodes":GRAPH_SIZE,
"nb_edges":EDGE_SIZE,
"coords":["random","country"],
}
......@@ -63,11 +65,14 @@ for method,args in pbar:
list_of_params = get_params(parameters[method])
func = getattr(ra,method)
for ix,params in enumerate(list_of_params):
# try:
G = func(**params)
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)
params["nb_edges"] = params["nb_edges"]*params["nb_nodes"]
print(params)
try:
G = func(**params)
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)
print("Can't generate graphs using these parameters")
......@@ -101,7 +101,7 @@ def _conf_model(degree_seq):
return G
def powerlaw_graph(nb_nodes, nb_edges, exponent=2, tries=1000, min_deg=1):
def powerlaw_graph(nb_nodes, nb_edges, exponent=2, tries=1000, min_deg=0):
"""
Generate a graph with a defined number of vertices, edges, and a degree distribution that fit the power law.
Using the Molloy-Reed algorithm to
......@@ -186,7 +186,7 @@ def spatial_graph(nb_nodes, nb_edges, coords="country", dist_func=lambda a, b: n
for j in range(nb_nodes):
if i == j and not self_link:
continue
data.append([i, j, dist_func(coords[i], coords[j])])
data.append([i, j, 1/(1+(dist_func(coords[i], coords[j])**2))])
df = pd.DataFrame(data, columns="src tar weight".split()).astype({"src": int, "tar": int})
df["hash"] = df.apply(lambda x: "_".join(sorted([str(int(x.src)), str(int(x.tar))])), axis=1)
df = df.drop_duplicates(subset="hash")
......@@ -259,7 +259,7 @@ def stochastic_block_model_graph(nb_nodes, nb_edges, nb_com, percentage_edge_bet
percentage_edge_within = 1 - percentage_edge_betw
G = nx.planted_partition_graph(nb_com, int(np.round(nb_nodes / nb_com)), 1, 1)
G = nx.planted_partition_graph(nb_com, nb_nodes//nb_com, 1, 1)
if verbose:
print(G.size())
......
......@@ -21,7 +21,7 @@ args = parser.parse_args()
fns = sorted(glob.glob(args.dataset_dir + "/*." + args.format))
def run_eval(fn):
command = "python evalNE_script.py {0} -f {1} -n".format(fn, args.format).split()
command = "python evalNE_script.py {0} -f {1}".format(fn, args.format).split()
output = subprocess.run(command)
if not output.returncode == 0:
print("Error! for the command :", " ".join(command))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment