parser.add_argument("graph",help="Name of the graph to be used.",choices=['checkins-foursquare','checkins-gowalla','checkins-brightkite','friends-foursquare','friends-gowalla','friends-brightkite'])
parser.add_argument("--k",help="Percentage of nodes to be sampled. Needs to be a float between 0 and 1. Default is 0.",default=0,type=float)
parser.add_argument("--nrand",help="Number of random graphs. Needs to be an integer. Default is 12",default=12,type=int)
parser.add_argument("--niter",help="Approximate number of rewiring per edge to compute the equivalent random graph. Default is 12",default=12,type=int)
parser.add_argument("--processes",help="Number of processes to be used. Needs to be an integer. Default is the number of cores.",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)
parser.add_help=True
args=parser.parse_args()
# check if the number of processes is valid
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")
# the name of the graph is the first part of the input string
name=args.graph.split('-')[1]
if'checkins'inargs.graph:
G=create_graph_from_checkins(name)#function from utils.py, check it out there
elif'friends'inargs.graph:
G=create_friendships_graph(name)#function from utils.py, check it out there
G.name=str(args.graph)+" Checkins Graph"
print("\nThe full graph {} has {} nodes and {} edges".format(args.graph,len(G),G.number_of_edges()))
print("Number of processes used: ",args.processes)
start=time.time()
# function from utils.py, check it out there (it's the parallel version of the omega index)