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("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("--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("--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("--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("--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_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
parser.add_help=True
args=parser.parse_args()
args=parser.parse_args()
# check if the number of processes is valid
ifargs.processes>multiprocessing.cpu_count():
ifargs.processes>multiprocessing.cpu_count():
print("Number of processes is higher than available. Setting it to default value: all available")
print("Number of processes is higher than available. Setting it to default value: all available")
args.processes=multiprocessing.cpu_count()
args.processes=multiprocessing.cpu_count()
elifargs.processes<1:
elifargs.processes<1:
raiseValueError("Number of processes needs to be at least 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]
name=args.graph.split('-')[1]
if'checkins'inargs.graph:
if'checkins'inargs.graph:
G=create_graph_from_checkins(name)
G=create_graph_from_checkins(name)#function from utils.py, check it out there
elif'friends'inargs.graph:
elif'friends'inargs.graph:
G=create_friendships_graph(name)
G=create_friendships_graph(name)#function from utils.py, check it out there
G.name=str(args.graph)+" Checkins Graph"
G.name=str(args.graph)+" Checkins Graph"
print("\nComputing omega for graph {} with{} nodes and {} edges".format(args.graph,len(G),G.number_of_edges()))
print("\nThe full graph {} has {} nodes and {} edges".format(args.graph,len(G),G.number_of_edges()))
print("Number of processes used: ",args.processes)
print("Number of processes used: ",args.processes)
start=time.time()
start=time.time()
# function from utils.py, check it out there (it's the parallel version of the omega index)
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("k",help="Percentage of nodes to be sampled. Needs to be a float between 0 and 1")
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=0)
parser.add_argument("--niter",help="Number of rewiring per edge. Needs to be an integer. Default is 5",default=5)
parser.add_argument("--niter",help="Number of rewiring per edge. Needs to be an integer. Default is 5",default=5)
parser.add_argument("--nrand",help="Number of random graphs. Needs to be an integer. Default is 5",default=5)
parser.add_argument("--nrand",help="Number of random graphs. Needs to be an integer. Default is 5",default=5)
parser.add_help=True
parser.add_help=True
args=parser.parse_args()
args=parser.parse_args()
@ -45,12 +38,12 @@ if __name__ == "__main__":
G.name=str(args.graph)+" Checkins Graph"
G.name=str(args.graph)+" Checkins Graph"
# sample the graph
# sample the graph
G_sample=random_sample(G,float(args.k))
G_sample=random_sample(G,float(args.k))# function from utils.py, check it out there
Thedatasetsaredownloadedinthe"data"folder.Ifthefolderdoesn't exist, it will be created. If the dataset is already downloaded, it will be skipped. The files are renamed to make them more readable.
Thedatasetsaredownloadedinthe"data"folder.Ifthefolderdoesn't exist, it will be created. If the dataset is already downloaded, it will be skipped. The files are renamed to make them more readable.