From 95e3b6a5c83c9c87f7a47a1865b66549c45eb02f Mon Sep 17 00:00:00 2001 From: Teddy Xinyuan Chen <45612704+tddschn@users.noreply.github.com> Date: Fri, 28 Apr 2023 10:24:11 +0800 Subject: [PATCH] 2023-04-28T10-24-11Z --- config.py | 9 +- profile_easygraph.py | 244 +++++++++++++++++++++++++++++--- profile_easygraph_undirected.py | 226 ++++++++++++++++++++++++++--- profile_graphtool.py | 52 ++----- profile_graphtool_undirected.py | 40 ++---- profile_igraph.py | 72 +++++----- profile_igraph_undirected.py | 58 ++++---- profile_networkit.py | 57 +++++++- profile_networkit_undirected.py | 39 ++++- profile_networkx.py | 85 +++++++++-- profile_networkx_undirected.py | 67 +++++++-- profile_snap.py | 52 ++----- 12 files changed, 754 insertions(+), 247 deletions(-) diff --git a/config.py b/config.py index 0135706..09c7808 100644 --- a/config.py +++ b/config.py @@ -264,14 +264,15 @@ } easygraph_multipcoessing_methods_for_paper = { - 'betweenness_centrality', - 'closeness_centrality', + # 'betweenness_centrality', + # 'closeness_centrality', 'constraint', - 'hierarchy', + # 'hierarchy', } easygraph_multiprocessing_n_workers_options = [2, 4, 8] -easygraph_multiprocessing_n_workers_options_for_paper = [2, 4] +# easygraph_multiprocessing_n_workers_options_for_paper = [2, 4] +easygraph_multiprocessing_n_workers_options_for_paper = [2, 4, 8] dataset_homepage_mapping = { 'cheminformatics': 'https://networkrepository.com/ENZYMES-g1.php', 'bio': 'https://networkrepository.com/bio-yeast.php', diff --git a/profile_easygraph.py b/profile_easygraph.py index 7495177..7cfb39d 100755 --- a/profile_easygraph.py +++ b/profile_easygraph.py @@ -8,7 +8,7 @@ import easygraph as eg import easygraph # from easygraph import * # type: ignore -from easygraph import Dijkstra, pagerank, strongly_connected_components, read_edgelist, multi_source_dijkstra, k_core, betweenness_centrality, closeness_centrality, connected_components, connected_components_directed +from easygraph import Dijkstra, pagerank, strongly_connected_components, read_edgelist, multi_source_dijkstra, k_core, betweenness_centrality, closeness_centrality, connected_components, connected_components_directed, clustering, constraint from benchmark import benchmark_autorange @@ -80,16 +80,30 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph -# 'read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.DiGraph()).cpp()' contains quotes -avg_times |= {'loading': benchmark_autorange('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.DiGraph()).cpp()', globals=globals(), n=n) } + + +# 'read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.DiGraph())' contains quotes +avg_times |= {'loading': benchmark_autorange('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.DiGraph())', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back # loading* only, make g in the globals() so the methods after loading methods can access it. -g = eval('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.DiGraph()).cpp()') + +g_py = eval('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.DiGraph())') +g = g_py.cpp() +g_cpp = g + + if args.print_graph_info: @@ -103,13 +117,12 @@ def get_args(): - - - + # networkx & easygraph only, after loading* from utils import get_first_node nodeid = 'first_node' first_node = get_first_node(g) + @@ -120,12 +133,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # 'pagerank(g)' contains quotes avg_times |= {'page rank': benchmark_autorange('pagerank(g)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -137,12 +159,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # f'Dijkstra(g, {nodeid})' contains quotes avg_times |= {'shortest path': benchmark_autorange(f'Dijkstra(g, {nodeid})', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -154,12 +185,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # 'betweenness_centrality(g)' contains quotes avg_times |= {'betweenness centrality': benchmark_autorange('betweenness_centrality(g)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -171,12 +211,167 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # 'closeness_centrality(g)' contains quotes avg_times |= {'closeness centrality': benchmark_autorange('closeness_centrality(g)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + + + + + + +# =========================== +print(f"""Profiling \033[92mclustering\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + + + + +# 'clustering(g)' contains quotes +avg_times |= {'clustering': benchmark_autorange('clustering(g)', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + + + + + + +# =========================== +print(f"""Profiling \033[92mconstraint\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + +g = g_py + + + + + +# 'constraint(g)' contains quotes +avg_times |= {'constraint': benchmark_autorange('constraint(g)', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + +g = g_cpp + + + + + + +# =========================== +print(f"""Profiling \033[92mconstraint-2-workers\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + +g = g_py + + + + + +# 'constraint(g, n_workers=2)' contains quotes +avg_times |= {'constraint-2-workers': benchmark_autorange('constraint(g, n_workers=2)', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + +g = g_cpp + + + + + + +# =========================== +print(f"""Profiling \033[92mconstraint-4-workers\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + +g = g_py + + + + + +# 'constraint(g, n_workers=4)' contains quotes +avg_times |= {'constraint-4-workers': benchmark_autorange('constraint(g, n_workers=4)', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + +g = g_cpp + + + + + + +# =========================== +print(f"""Profiling \033[92mconstraint-8-workers\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + +g = g_py + + + + + +# 'constraint(g, n_workers=8)' contains quotes +avg_times |= {'constraint-8-workers': benchmark_autorange('constraint(g, n_workers=8)', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + +g = g_cpp + @@ -188,12 +383,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # '[i for i in strongly_connected_components(g)]' contains quotes avg_times |= {'strongly connected components': benchmark_autorange('[i for i in strongly_connected_components(g)]', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -205,35 +409,43 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph -# remove self loop from graph g before doing k-core + -# if tool is easygraph +# remove self loop from graph g before doing k-core + +# if tool is easygraph + # give eg access to a python version of Graph first, so that removing self loops is possible # eval code.removesuffix('.cpp()') -g_og = g -g_python = g.py() +g_python = g_py g = g_python g.remove_edges(easygraph.selfloop_edges(g)) g = g.cpp() + + + - - - - - + # 'k_core(g)' contains quotes avg_times |= {'k-core': benchmark_autorange('k_core(g)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + diff --git a/profile_easygraph_undirected.py b/profile_easygraph_undirected.py index 2a6a4de..ac23c4a 100755 --- a/profile_easygraph_undirected.py +++ b/profile_easygraph_undirected.py @@ -8,7 +8,7 @@ import easygraph as eg import easygraph # from easygraph import * # type: ignore -from easygraph import Dijkstra, pagerank, strongly_connected_components, read_edgelist, multi_source_dijkstra, k_core, betweenness_centrality, closeness_centrality, connected_components, connected_components_directed +from easygraph import Dijkstra, pagerank, strongly_connected_components, read_edgelist, multi_source_dijkstra, k_core, betweenness_centrality, closeness_centrality, connected_components, connected_components_directed, clustering, constraint from benchmark import benchmark_autorange @@ -80,16 +80,30 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph -# 'read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.Graph()).cpp()' contains quotes -avg_times |= {'loading_undirected': benchmark_autorange('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.Graph()).cpp()', globals=globals(), n=n) } + + +# 'read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.Graph())' contains quotes +avg_times |= {'loading_undirected': benchmark_autorange('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.Graph())', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back # loading* only, make g in the globals() so the methods after loading methods can access it. -g = eval('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.Graph()).cpp()') + +g_py = eval('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=eg.Graph())') +g = g_py.cpp() +g_cpp = g + + if args.print_graph_info: @@ -103,13 +117,12 @@ def get_args(): - - - + # networkx & easygraph only, after loading* from utils import get_first_node nodeid = 'first_node' first_node = get_first_node(g) + @@ -120,12 +133,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # f'Dijkstra(g, {nodeid})' contains quotes avg_times |= {'shortest path': benchmark_autorange(f'Dijkstra(g, {nodeid})', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -137,12 +159,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # 'betweenness_centrality(g)' contains quotes avg_times |= {'betweenness centrality': benchmark_autorange('betweenness_centrality(g)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -154,12 +185,167 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # 'closeness_centrality(g)' contains quotes avg_times |= {'closeness centrality': benchmark_autorange('closeness_centrality(g)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + + + + + + +# =========================== +print(f"""Profiling \033[92mclustering\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + + + + +# 'clustering(g)' contains quotes +avg_times |= {'clustering': benchmark_autorange('clustering(g)', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + + + + + + +# =========================== +print(f"""Profiling \033[92mconstraint\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + +g = g_py + + + + + +# 'constraint(g)' contains quotes +avg_times |= {'constraint': benchmark_autorange('constraint(g)', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + +g = g_cpp + + + + + + +# =========================== +print(f"""Profiling \033[92mconstraint-2-workers\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + +g = g_py + + + + + +# 'constraint(g, n_workers=2)' contains quotes +avg_times |= {'constraint-2-workers': benchmark_autorange('constraint(g, n_workers=2)', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + +g = g_cpp + + + + + + +# =========================== +print(f"""Profiling \033[92mconstraint-4-workers\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + +g = g_py + + + + + +# 'constraint(g, n_workers=4)' contains quotes +avg_times |= {'constraint-4-workers': benchmark_autorange('constraint(g, n_workers=4)', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + +g = g_cpp + + + + + + +# =========================== +print(f"""Profiling \033[92mconstraint-8-workers\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + +g = g_py + + + + + +# 'constraint(g, n_workers=8)' contains quotes +avg_times |= {'constraint-8-workers': benchmark_autorange('constraint(g, n_workers=8)', globals=globals(), n=n) } + +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + +g = g_cpp + @@ -171,35 +357,43 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph -# remove self loop from graph g before doing k-core + -# if tool is easygraph +# remove self loop from graph g before doing k-core + +# if tool is easygraph + # give eg access to a python version of Graph first, so that removing self loops is possible # eval code.removesuffix('.cpp()') -g_og = g -g_python = g.py() +g_python = g_py g = g_python g.remove_edges(easygraph.selfloop_edges(g)) g = g.cpp() + + + - - - - - + # 'k_core(g)' contains quotes avg_times |= {'k-core': benchmark_autorange('k_core(g)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + diff --git a/profile_graphtool.py b/profile_graphtool.py index 7165391..b63e45d 100755 --- a/profile_graphtool.py +++ b/profile_graphtool.py @@ -72,26 +72,8 @@ def get_args(): print() - -# '''load_graph_from_csv(filename, directed=True, csv_options={'delimiter': '\t', 'quotechar': '"'})''' contains quotes -avg_times |= {'loading': benchmark_autorange('''load_graph_from_csv(filename, directed=True, csv_options={'delimiter': '\t', 'quotechar': '"'})''', globals=globals(), n=n) } - - - -# loading* only, make g in the globals() so the methods after loading methods can access it. -g = eval('''load_graph_from_csv(filename, directed=True, csv_options={'delimiter': '\t', 'quotechar': '"'})''') - -if args.print_graph_info: - - print('graphtool does not support printing graph info.') - - - if args.print_graph_info_only: - sys.exit(0) - - - - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -103,10 +85,8 @@ def get_args(): print() - -# "shortest_distance(g, g.vertex(0), max_dist=2).a" contains quotes -avg_times |= {'2-hops': benchmark_autorange("shortest_distance(g, g.vertex(0), max_dist=2).a", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -118,10 +98,8 @@ def get_args(): print() - -# "shortest_distance(g, g.vertex(0)).a" contains quotes -avg_times |= {'shortest path': benchmark_autorange("shortest_distance(g, g.vertex(0)).a", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -133,10 +111,8 @@ def get_args(): print() - -# 'pagerank(g, damping=0.85, epsilon=1e-3, max_iter=10000000).a' contains quotes -avg_times |= {'page rank': benchmark_autorange('pagerank(g, damping=0.85, epsilon=1e-3, max_iter=10000000).a', globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -148,10 +124,8 @@ def get_args(): print() - -# 'kcore_decomposition(g).a' contains quotes -avg_times |= {'k-core': benchmark_autorange('kcore_decomposition(g).a', globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -163,10 +137,8 @@ def get_args(): print() - -# 'cc, _ = label_components(g, vprop=None, directed=True, attractors=False); cc.a' contains quotes -avg_times |= {'strongly connected components': benchmark_autorange('cc, _ = label_components(g, vprop=None, directed=True, attractors=False); cc.a', globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph diff --git a/profile_graphtool_undirected.py b/profile_graphtool_undirected.py index 68361c2..b19ea8a 100755 --- a/profile_graphtool_undirected.py +++ b/profile_graphtool_undirected.py @@ -72,26 +72,8 @@ def get_args(): print() - -# '''load_graph_from_csv(filename, directed=False, csv_options={'delimiter': '\t', 'quotechar': '"'})''' contains quotes -avg_times |= {'loading_undirected': benchmark_autorange('''load_graph_from_csv(filename, directed=False, csv_options={'delimiter': '\t', 'quotechar': '"'})''', globals=globals(), n=n) } - - - -# loading* only, make g in the globals() so the methods after loading methods can access it. -g = eval('''load_graph_from_csv(filename, directed=False, csv_options={'delimiter': '\t', 'quotechar': '"'})''') - -if args.print_graph_info: - - print('graphtool does not support printing graph info.') - - - if args.print_graph_info_only: - sys.exit(0) - - - - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -103,10 +85,8 @@ def get_args(): print() - -# "shortest_distance(g, g.vertex(0), max_dist=2).a" contains quotes -avg_times |= {'2-hops': benchmark_autorange("shortest_distance(g, g.vertex(0), max_dist=2).a", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -118,10 +98,8 @@ def get_args(): print() - -# "shortest_distance(g, g.vertex(0)).a" contains quotes -avg_times |= {'shortest path': benchmark_autorange("shortest_distance(g, g.vertex(0)).a", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -133,10 +111,8 @@ def get_args(): print() - -# 'kcore_decomposition(g).a' contains quotes -avg_times |= {'k-core': benchmark_autorange('kcore_decomposition(g).a', globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph diff --git a/profile_igraph.py b/profile_igraph.py index 7756dda..5724cbb 100755 --- a/profile_igraph.py +++ b/profile_igraph.py @@ -72,88 +72,86 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph -# "Graph.Read(filename, format='edges')" contains quotes -avg_times |= {'loading': benchmark_autorange("Graph.Read(filename, format='edges')", globals=globals(), n=n) } -# loading* only, make g in the globals() so the methods after loading methods can access it. -g = eval("Graph.Read(filename, format='edges')") -if args.print_graph_info: - - # get the # of nodes and edges and print - print(f"{g.vcount()=}, {g.ecount()=}") +# =========================== +print(f"""Profiling \033[92mshortest path\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() - - if args.print_graph_info_only: - sys.exit(0) +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph +# =========================== +print(f"""Profiling \033[92mpage rank\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + # =========================== -print(f"""Profiling \033[92mshortest path\033[0m on dataset \033[34m{filename}\033[0m""") +print(f"""Profiling \033[92mbetweenness centrality\033[0m on dataset \033[34m{filename}\033[0m""") print("=================") print() - -# "g.distances(source=[g.vs[0]], weights=[1]*len(g.es), )" contains quotes -avg_times |= {'shortest path': benchmark_autorange("g.distances(source=[g.vs[0]], weights=[1]*len(g.es), )", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph # =========================== -print(f"""Profiling \033[92mpage rank\033[0m on dataset \033[34m{filename}\033[0m""") +print(f"""Profiling \033[92mcloseness centrality\033[0m on dataset \033[34m{filename}\033[0m""") print("=================") print() - -# "g.pagerank(damping=0.85)" contains quotes -avg_times |= {'page rank': benchmark_autorange("g.pagerank(damping=0.85)", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph # =========================== -print(f"""Profiling \033[92mbetweenness centrality\033[0m on dataset \033[34m{filename}\033[0m""") +print(f"""Profiling \033[92mclustering\033[0m on dataset \033[34m{filename}\033[0m""") print("=================") print() - -# "g.betweenness()" contains quotes -avg_times |= {'betweenness centrality': benchmark_autorange("g.betweenness()", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph # =========================== -print(f"""Profiling \033[92mcloseness centrality\033[0m on dataset \033[34m{filename}\033[0m""") +print(f"""Profiling \033[92mconstraint\033[0m on dataset \033[34m{filename}\033[0m""") print("=================") print() - -# "g.closeness()" contains quotes -avg_times |= {'closeness centrality': benchmark_autorange("g.closeness()", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -165,10 +163,8 @@ def get_args(): print() - -# "g.coreness(mode='all')" contains quotes -avg_times |= {'k-core': benchmark_autorange("g.coreness(mode='all')", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -180,10 +176,8 @@ def get_args(): print() - -# "[i for i in g.components(mode=STRONG)]" contains quotes -avg_times |= {'strongly connected components': benchmark_autorange("[i for i in g.components(mode=STRONG)]", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph diff --git a/profile_igraph_undirected.py b/profile_igraph_undirected.py index 04f771b..86aeeb4 100755 --- a/profile_igraph_undirected.py +++ b/profile_igraph_undirected.py @@ -72,73 +72,73 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph -# "Graph.Read(filename, format='edges', directed=False)" contains quotes -avg_times |= {'loading_undirected': benchmark_autorange("Graph.Read(filename, format='edges', directed=False)", globals=globals(), n=n) } -# loading* only, make g in the globals() so the methods after loading methods can access it. -g = eval("Graph.Read(filename, format='edges', directed=False)") -if args.print_graph_info: - - # get the # of nodes and edges and print - print(f"{g.vcount()=}, {g.ecount()=}") +# =========================== +print(f"""Profiling \033[92mshortest path\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph - - if args.print_graph_info_only: - sys.exit(0) +# =========================== +print(f"""Profiling \033[92mbetweenness centrality\033[0m on dataset \033[34m{filename}\033[0m""") +print("=================") +print() + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph # =========================== -print(f"""Profiling \033[92mshortest path\033[0m on dataset \033[34m{filename}\033[0m""") +print(f"""Profiling \033[92mcloseness centrality\033[0m on dataset \033[34m{filename}\033[0m""") print("=================") print() - -# "g.distances(source=[g.vs[0]], weights=[1]*len(g.es), )" contains quotes -avg_times |= {'shortest path': benchmark_autorange("g.distances(source=[g.vs[0]], weights=[1]*len(g.es), )", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph # =========================== -print(f"""Profiling \033[92mbetweenness centrality\033[0m on dataset \033[34m{filename}\033[0m""") +print(f"""Profiling \033[92mclustering\033[0m on dataset \033[34m{filename}\033[0m""") print("=================") print() - -# "g.betweenness()" contains quotes -avg_times |= {'betweenness centrality': benchmark_autorange("g.betweenness()", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph # =========================== -print(f"""Profiling \033[92mcloseness centrality\033[0m on dataset \033[34m{filename}\033[0m""") +print(f"""Profiling \033[92mconstraint\033[0m on dataset \033[34m{filename}\033[0m""") print("=================") print() - -# "g.closeness()" contains quotes -avg_times |= {'closeness centrality': benchmark_autorange("g.closeness()", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -150,10 +150,8 @@ def get_args(): print() - -# "g.coreness(mode='all')" contains quotes -avg_times |= {'k-core': benchmark_autorange("g.coreness(mode='all')", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph diff --git a/profile_networkit.py b/profile_networkit.py index c64d27e..d217af7 100755 --- a/profile_networkit.py +++ b/profile_networkit.py @@ -72,16 +72,28 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # "nk.graphio.EdgeListReader(separator='\t', firstNode=0, continuous=True, directed =True).read(filename)" contains quotes avg_times |= {'loading': benchmark_autorange("nk.graphio.EdgeListReader(separator='\t', firstNode=0, continuous=True, directed =True).read(filename)", globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + # loading* only, make g in the globals() so the methods after loading methods can access it. + g = eval("nk.graphio.EdgeListReader(separator='\t', firstNode=0, continuous=True, directed =True).read(filename)") + + if args.print_graph_info: @@ -93,8 +105,7 @@ def get_args(): - - + @@ -105,12 +116,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # "nk.distance.BFS(g, 0, storePaths=False).run().getDistances(False)" contains quotes avg_times |= {'shortest path': benchmark_autorange("nk.distance.BFS(g, 0, storePaths=False).run().getDistances(False)", globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -122,12 +142,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # "nk.centrality.PageRank(g, damp=0.85, tol=1e-3).run().scores()" contains quotes avg_times |= {'page rank': benchmark_autorange("nk.centrality.PageRank(g, damp=0.85, tol=1e-3).run().scores()", globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -139,12 +168,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # "nk.components.StronglyConnectedComponents(g).run().getPartition().getVector()" contains quotes avg_times |= {'strongly connected components': benchmark_autorange("nk.components.StronglyConnectedComponents(g).run().getPartition().getVector()", globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -156,21 +194,30 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph -# remove self loop from graph g before doing k-core + +# remove self loop from graph g before doing k-core + + g.removeSelfLoops() - - + # "nk.centrality.CoreDecomposition(g).run().scores()" contains quotes avg_times |= {'k-core': benchmark_autorange("nk.centrality.CoreDecomposition(g).run().scores()", globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + diff --git a/profile_networkit_undirected.py b/profile_networkit_undirected.py index c6d387f..3fab920 100755 --- a/profile_networkit_undirected.py +++ b/profile_networkit_undirected.py @@ -72,16 +72,28 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # "nk.graphio.EdgeListReader(separator='\t', firstNode=0, continuous=True).read(filename)" contains quotes avg_times |= {'loading_undirected': benchmark_autorange("nk.graphio.EdgeListReader(separator='\t', firstNode=0, continuous=True).read(filename)", globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + # loading* only, make g in the globals() so the methods after loading methods can access it. + g = eval("nk.graphio.EdgeListReader(separator='\t', firstNode=0, continuous=True).read(filename)") + + if args.print_graph_info: @@ -93,8 +105,7 @@ def get_args(): - - + @@ -105,12 +116,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # "nk.distance.BFS(g, 0, storePaths=False).run().getDistances(False)" contains quotes avg_times |= {'shortest path': benchmark_autorange("nk.distance.BFS(g, 0, storePaths=False).run().getDistances(False)", globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -122,21 +142,30 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph -# remove self loop from graph g before doing k-core + +# remove self loop from graph g before doing k-core + + g.removeSelfLoops() - - + # "nk.centrality.CoreDecomposition(g).run().scores()" contains quotes avg_times |= {'k-core': benchmark_autorange("nk.centrality.CoreDecomposition(g).run().scores()", globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + diff --git a/profile_networkx.py b/profile_networkx.py index 2d4726d..7f2cc13 100755 --- a/profile_networkx.py +++ b/profile_networkx.py @@ -74,16 +74,28 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # 'read_edgelist(filename, delimiter="\t", nodetype=int, create_using=nx.DiGraph())' contains quotes avg_times |= {'loading': benchmark_autorange('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=nx.DiGraph())', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + # loading* only, make g in the globals() so the methods after loading methods can access it. + g = eval('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=nx.DiGraph())') + + if args.print_graph_info: @@ -95,13 +107,12 @@ def get_args(): - - - + # networkx & easygraph only, after loading* from utils import get_first_node nodeid = 'first_node' first_node = get_first_node(g) + @@ -112,12 +123,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # f'single_source_shortest_path_length(g, {nodeid}, cutoff=2)' contains quotes avg_times |= {'2-hops': benchmark_autorange(f'single_source_shortest_path_length(g, {nodeid}, cutoff=2)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -129,12 +149,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # f'shortest_path_length(g, {nodeid})' contains quotes avg_times |= {'shortest path': benchmark_autorange(f'shortest_path_length(g, {nodeid})', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -146,12 +175,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # 'pagerank(g, alpha=0.85, tol=1e-3, max_iter=10000000)' contains quotes avg_times |= {'page rank': benchmark_autorange('pagerank(g, alpha=0.85, tol=1e-3, max_iter=10000000)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -163,12 +201,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # '[i for i in strongly_connected_components(g)]' contains quotes avg_times |= {'strongly connected components': benchmark_autorange('[i for i in strongly_connected_components(g)]', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -180,12 +227,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # '[i for i in connected_components(g)]' contains quotes avg_times |= {'connected components': benchmark_autorange('[i for i in connected_components(g)]', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -197,28 +253,37 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph -# remove self loop from graph g before doing k-core - -# if tool is easygraph + +# remove self loop from graph g before doing k-core + +# if tool is easygraph + + g.remove_edges_from(networkx.selfloop_edges(g)) + + - - - - + # 'core.core_number(g)' contains quotes avg_times |= {'k-core': benchmark_autorange('core.core_number(g)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + diff --git a/profile_networkx_undirected.py b/profile_networkx_undirected.py index 35fa2a7..1a9e607 100755 --- a/profile_networkx_undirected.py +++ b/profile_networkx_undirected.py @@ -74,16 +74,28 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # 'read_edgelist(filename, delimiter="\t", nodetype=int, create_using=nx.Graph())' contains quotes avg_times |= {'loading_undirected': benchmark_autorange('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=nx.Graph())', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + # loading* only, make g in the globals() so the methods after loading methods can access it. + g = eval('read_edgelist(filename, delimiter="\t", nodetype=int, create_using=nx.Graph())') + + if args.print_graph_info: @@ -95,13 +107,12 @@ def get_args(): - - - + # networkx & easygraph only, after loading* from utils import get_first_node nodeid = 'first_node' first_node = get_first_node(g) + @@ -112,12 +123,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # f'single_source_shortest_path_length(g, {nodeid}, cutoff=2)' contains quotes avg_times |= {'2-hops': benchmark_autorange(f'single_source_shortest_path_length(g, {nodeid}, cutoff=2)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -129,12 +149,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # f'shortest_path_length(g, {nodeid})' contains quotes avg_times |= {'shortest path': benchmark_autorange(f'shortest_path_length(g, {nodeid})', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -146,12 +175,21 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph + + # '[i for i in connected_components(g)]' contains quotes avg_times |= {'connected components': benchmark_autorange('[i for i in connected_components(g)]', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + @@ -163,28 +201,37 @@ def get_args(): print() +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph -# remove self loop from graph g before doing k-core - -# if tool is easygraph + +# remove self loop from graph g before doing k-core + +# if tool is easygraph + + g.remove_edges_from(networkx.selfloop_edges(g)) + + - - - - + # 'core.core_number(g)' contains quotes avg_times |= {'k-core': benchmark_autorange('core.core_number(g)', globals=globals(), n=n) } +# if tool starts with 'constraint' and + +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then convert g back + diff --git a/profile_snap.py b/profile_snap.py index d56dd84..28d4d8e 100755 --- a/profile_snap.py +++ b/profile_snap.py @@ -72,26 +72,8 @@ def get_args(): print() - -# "snap.LoadEdgeListStr(snap.PNGraph, filename, 0, 1)" contains quotes -avg_times |= {'loading': benchmark_autorange("snap.LoadEdgeListStr(snap.PNGraph, filename, 0, 1)", globals=globals(), n=n) } - - - -# loading* only, make g in the globals() so the methods after loading methods can access it. -g = eval("snap.LoadEdgeListStr(snap.PNGraph, filename, 0, 1)") - -if args.print_graph_info: - - print('snap does not support printing graph info.') - - - if args.print_graph_info_only: - sys.exit(0) - - - - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -103,10 +85,8 @@ def get_args(): print() - -# "snap.GetNodesAtHop(g, 0, 2, NodeVec, True)" contains quotes -avg_times |= {'2-hops': benchmark_autorange("snap.GetNodesAtHop(g, 0, 2, NodeVec, True)", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -118,10 +98,8 @@ def get_args(): print() - -# "snap.GetShortPath(g, 0, NIdToDistH, True)" contains quotes -avg_times |= {'shortest path': benchmark_autorange("snap.GetShortPath(g, 0, NIdToDistH, True)", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -133,10 +111,8 @@ def get_args(): print() - -# "snap.GetPageRank(g, PRankH, 0.85, 1e-3, 10000000)" contains quotes -avg_times |= {'page rank': benchmark_autorange("snap.GetPageRank(g, PRankH, 0.85, 1e-3, 10000000)", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -148,10 +124,8 @@ def get_args(): print() - -# "snap.GetKCoreNodes(g, CoreIDSzV)" contains quotes -avg_times |= {'k-core': benchmark_autorange("snap.GetKCoreNodes(g, CoreIDSzV)", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph @@ -163,10 +137,8 @@ def get_args(): print() - -# "snap.GetSccs(g, Components)" contains quotes -avg_times |= {'strongly connected components': benchmark_autorange("snap.GetSccs(g, Components)", globals=globals(), n=n) } - +# easygraph constraint doesn't have c bindings +# if method starts with 'constraint', then use python version of graph