nx_bench.py 986 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/env python
from __future__ import print_function

from networkx import *
import cProfile

g = read_graphml("pgp.xml")

print("Profiling shortest path")
print("=======================")
print()

cProfile.run("for i in range(100): shortest_path_length(g, 'n0')", sort="cumulative")


print("Profiling PageRank")
print("==================")
print()

cProfile.run("for i in range(10): pagerank(g, alpha=0.85, tol=1e-3, max_iter=10000000)", sort="cumulative")

print("Profiling k-core")
print("================")
print()

cProfile.run("for i in range(10): core.core_number(g)", sort="cumulative")


print("Profiling minimum spanning tree")
print("===============================")
print()

u = g.to_undirected()

cProfile.run("for i in range(10): minimum_spanning_tree(u)", sort="cumulative")

'''
print("Profiling betweenness")
print("====================")
print()

cProfile.run("for i in range(1): betweenness_centrality(g); edge_betweenness_centrality(g)", sort="cumulative")
'''