parser.add_argument("graph",help="Name of the graph to be used. Options are 'checkins-foursquare', 'checkins-gowalla', 'checkins-brightkite', 'friends-foursquare', 'friends-gowalla', 'friends-brightkite'")
forgraphingraphs[::-1]:
print("\nComputing omega for graph: ",graph)
parser.add_argument("--k",help="Percentage of nodes to be sampled. Needs to be a float between 0 and 1. Default is 0.1",default=None,type=float)
print("Number of processes used: ",multiprocessing.cpu_count())
if'checkins'ingraph:
parser.add_argument("--nrand",help="Number of random graphs. Needs to be an integer. Default is 5",default=12,type=int)
G=create_graph_from_checkins(graph.split('-')[1])
elif'friends'ingraph:
parser.add_argument("--niter",help="Approximate number of rewiring per edge to compute the equivalent random graph. Default is 12",default=12,type=int)
G=create_friendships_graph(graph.split('-')[1])
parser.add_argument("--processes",help="Number of processes to be used. Needs to be an integer. Default is all available",default=multiprocessing.cpu_count(),type=int)
parser.add_argument("--seed",help="Seed for the random number generator. Needs to be an integer. Default is 42",default=42,type=int)
raiseValueError("Graph name is not valid. Options are 'checkins-foursquare', 'checkins-gowalla', 'checkins-brightkite', 'friends-foursquare', 'friends-gowalla', 'friends-brightkite'")
ifargs.processes>multiprocessing.cpu_count():
print("Number of processes is higher than available. Setting it to default value: all available")
args.processes=multiprocessing.cpu_count()
elifargs.processes<1:
raiseValueError("Number of processes needs to be at least 1")
name=args.graph.split('-')[1]
if'checkins'inargs.graph:
G=create_graph_from_checkins(name)
elif'friends'inargs.graph:
G=create_friendships_graph(name)
G.name=str(args.graph)+" Checkins Graph"
results={}
forgraphingraphs:
print("\nComputing omega for graph {} with {} nodes and {} edges".format(graph,len(G),G.number_of_edges()))
print("Number of processes used: ",multiprocessing.cpu_count())
print("Number of processes used: ",args.processes)
print("Time: ",end-start)
print("Time: ",end-start)
results[graph]=omega
results[graph]=omega
@ -91,49 +150,31 @@ if __name__ == "__main__":
forkeyinresults.keys():
forkeyinresults.keys():
f.write("%s\t%s\n"%(key,results[key]))
f.write("%s\t%s\n"%(key,results[key]))
# if __name__ == "__main__":
## Variant if you want to run it on a server for all the graphs
# parser = argparse.ArgumentParser()
# parser.add_argument("graph", help="Name of the graph to be used. Options are 'checkins-foursquare', 'checkins-gowalla', 'checkins-brightkite', 'friends-foursquare', 'friends-gowalla', 'friends-brightkite'")
# parser.add_argument("--nrand", help="Number of random graphs. Needs to be an integer. Default is 5", default=12, type=int)
# parser.add_argument("--processes", help="Number of processes to be used. Needs to be an integer. Default is all available", default=multiprocessing.cpu_count(), type=int)
# parser.add_argument("--seed", help="Seed for the random number generator. Needs to be an integer. Default is 42", default=42, type=int)
# raise ValueError("Graph name is not valid. Options are 'checkins-foursquare', 'checkins-gowalla', 'checkins-brightkite', 'friends-foursquare', 'friends-gowalla', 'friends-brightkite'")
# if args.processes > multiprocessing.cpu_count():
# print("Number of processes is higher than available. Setting it to default value: all available")
# args.processes = multiprocessing.cpu_count()
# elif args.processes < 1:
# raise ValueError("Number of processes needs to be at least 1")
# name = args.graph.split('-')[1]
# if 'checkins' in args.graph:
# G = create_graph_from_checkins(name)
# elif 'friends' in args.graph:
# G = create_friendships_graph(name)
# G.name = str(args.graph) + " Checkins Graph"
# if __name__ == "__main__":
# results = {}
# results = {}
# for graph in graphs:
# print("\nComputing omega for graph: ", G.name)
# # loop in reverse order
# for graph in graphs[::-1]:
# print("\nComputing omega for graph: ", graph)
# print("Number of processes used: ", multiprocessing.cpu_count())
# print("Number of processes used: ", multiprocessing.cpu_count())
# if 'checkins' in graph:
# G = create_graph_from_checkins(graph.split('-')[1])
# elif 'friends' in graph:
# G = create_friendships_graph(graph.split('-')[1])
Thisfileisnotemeanttoberun,it's just a collection of functions that are used in the other files. It'sjustawaytokeepthecodecleanandorganized.
-Thisfileisnotemeanttoberun,it's just a collection of functions that are used in the other files. It'sjustawaytokeepthecodecleanandorganized.
-WhydoIuseos.path.joinandnotthe"/"?Becauseit's more portable, it works on every OS, while "/" works only on Linux and Mac. In windows you would have to change all the "/" with "\". With os.path.join you don'thavetoworryaboutitand,asalways,f***Microsoft.