<s> from zen . util . benchmark import Benchmark <EOL> import networkx as nx <EOL> import zen as zn <EOL> import igraph as ig <EOL> import random <EOL> class AllPairsBenchmark ( Benchmark ) : <EOL> def __init__ ( self ) : <EOL> Benchmark . __init__ ( self , '<STR_LIT>' ) <EOL> self . NUM_NODES = <NUM_LIT:200> <EOL> self . NUM_SOURCES = <NUM_LIT:20> <EOL> self . P = <NUM_LIT> <EOL> def setup ( self ) : <EOL> self . ER_G = zn . Graph ( ) <EOL> for i in range ( self . NUM_NODES ) : <EOL> self . ER_G . add_node ( i ) <EOL> for i in range ( self . NUM_NODES ) : <EOL> for j in range ( i + <NUM_LIT:1> , self . NUM_NODES ) : <EOL> if random . random ( ) < self . P : <EOL> self . ER_G . add_edge_ ( i , j ) <EOL> def bm_floyd_warshall ( self ) : <EOL> zn . floyd_warshall_path_length_ ( self . ER_G ) <EOL> def bm_apsp ( self ) : <EOL> zn . all_pairs_shortest_path_length_ ( self . ER_G ) <EOL> def bm_apsp_dijkstra ( self ) : <EOL> zn . all_pairs_dijkstra_path_length_ ( self . ER_G ) <EOL> class UUERSSSPBenchmark ( Benchmark ) : <EOL> def __init__ ( self ) : <EOL> Benchmark . __init__ ( self , '<STR_LIT>' ) <EOL> self . NUM_NODES = <NUM_LIT:200> <EOL> self . NUM_SOURCES = <NUM_LIT:20> <EOL> self . P = <NUM_LIT> <EOL> def setup ( self ) : <EOL> self . ER_G = zn . Graph ( ) <EOL> for i in range ( self . NUM_NODES ) : <EOL> self . ER_G . add_node ( i ) <EOL> for i in range ( self . NUM_NODES ) : <EOL> for j in range ( i + <NUM_LIT:1> , self . NUM_NODES ) : <EOL> if random . random ( ) < self . P : <EOL> self . ER_G . add_edge_ ( i , j ) <EOL> self . sources = random . sample ( range ( self . NUM_NODES ) , self . NUM_SOURCES ) <EOL> def bm_zen ( self ) : <EOL> for i in self . sources : <EOL> zn . single_source_shortest_path ( self . ER_G , i ) <EOL> def bm_zenopt ( self ) : <EOL> for i in self . sources : <EOL> zn . single_source_shortest_path_ ( self . ER_G , i ) <EOL> def setup_networkx ( self ) : <EOL> self . nx_ER_G = nx . Graph ( ) <EOL> for i in self . ER_G . nodes_iter ( ) : <EOL> self . nx_ER_G . add_node ( i ) <EOL> for i , j in self . ER_G . edges_iter ( ) : <EOL> self . nx_ER_G . add_edge ( i , j ) <EOL> def bm_networkx ( self ) : <EOL> for i in self . sources : <EOL> nx . single_source_shortest_path ( self . nx_ER_G , i ) <EOL> def setup_igraph ( self ) : <EOL> self . ig_ER_G = ig . Graph ( ) <EOL> self . ig_ER_G . add_vertices ( len ( self . ER_G ) ) <EOL> self . ig_ER_G . add_edges ( self . ER_G . edges ( ) ) <EOL> def bm_igraph ( self ) : <EOL> for i in self . sources : <EOL> self . ig_ER_G . get_shortest_paths ( i ) <EOL> class UERDijkstraBenchmark ( Benchmark ) : <EOL> def __init__ ( self ) : <EOL> Benchmark . __init__ ( self , '<STR_LIT>' ) <EOL> self . NUM_NODES = <NUM_LIT:200> <EOL> self . NUM_SOURCES = <NUM_LIT:20> <EOL> self . P = <NUM_LIT> <EOL> def setup ( self ) : <EOL> self . ER_G = zn . Graph ( ) <EOL> for i in range ( self . NUM_NODES ) : <EOL> self . ER_G . add_node ( i ) <EOL> for i in range ( self . NUM_NODES ) : <EOL> for j in range ( i + <NUM_LIT:1> , self . NUM_NODES ) : <EOL> if random . random ( ) < self . P : <EOL> self . ER_G . add_edge_ ( i , j ) <EOL> self . sources = random . sample ( range ( self . NUM_NODES ) , self . NUM_SOURCES ) <EOL> def bm_zen ( self ) : <EOL> for i in self . sources : <EOL> zn . dijkstra_path ( self . ER_G , i ) <EOL> def bm_zenopt ( self ) : <EOL> for i in self . sources : <EOL> zn . dijkstra_path_ ( self . ER_G , i ) <EOL> def setup_networkx ( self ) : <EOL> self . nx_ER_G = nx . Graph ( ) <EOL> for i in self . ER_G . nodes_iter ( ) : <EOL> self . nx_ER_G . add_node ( i ) <EOL> for i , j in self . ER_G . edges_iter ( ) : <EOL> self . nx_ER_G . add_edge ( i , j ) <EOL> def bm_networkx ( self ) : <EOL> for i in self . sources : <EOL> nx . single_source_dijkstra ( self . nx_ER_G , i ) <EOL> def setup_igraph ( self ) : <EOL> self . ig_ER_G = ig . Graph ( ) <EOL> self . ig_ER_G . add_vertices ( len ( self . ER_G ) ) <EOL> self . ig_ER_G . add_edges ( self . ER_G . edges ( ) ) <EOL> def bm_igraph ( self ) : <EOL> for i in self . sources : <EOL> self . ig_ER_G . get_shortest_paths ( i ) <EOL> class UERFloydWarshallBenchmark ( Benchmark ) : <EOL> def __init__ ( self ) : <EOL> Benchmark . __init__ ( self , '<STR_LIT>' ) <EOL> self . NUM_NODES = <NUM_LIT:200> <EOL> self . NUM_SOURCES = <NUM_LIT:20> <EOL> self . P = <NUM_LIT> <EOL> def setup ( self ) : <EOL> self . ER_G = zn . Graph ( ) <EOL> for i in range ( self . NUM_NODES ) : <EOL> self . ER_G . add_node ( i ) <EOL> for i in range ( self . NUM_NODES ) : <EOL> for j in range ( i + <NUM_LIT:1> , self . NUM_NODES ) : <EOL> if random . random ( ) < self . P : <EOL> self . ER_G . add_edge_ ( i , j ) <EOL> def bm_zen ( self ) : <EOL> zn . floyd_warshall_path_length ( self . ER_G ) <EOL> def bm_zenopt ( self ) : <EOL> zn . floyd_warshall_path_length_ ( self . ER_G ) <EOL> def setup_networkx ( self ) : <EOL> self . nx_ER_G = nx . Graph ( ) <EOL> for i in self . ER_G . nodes_iter ( ) : <EOL> self . nx_ER_G . add_node ( i ) <EOL> for i , j in self . ER_G . edges_iter ( ) : <EOL> self . nx_ER_G . add_edge ( i , j ) <EOL> def bm_networkx ( self ) : <EOL> nx . floyd_warshall ( self . nx_ER_G ) <EOL> def setup_igraph ( self ) : <EOL> self . ig_ER_G = ig . Graph ( ) <EOL> self . ig_ER_G . add_vertices ( len ( self . ER_G ) ) <EOL> self . ig_ER_G . add_edges ( self . ER_G . edges ( ) ) <EOL> class UUERAPSPBenchmark ( Benchmark ) : <EOL> def __init__ ( self ) : <EOL> Benchmark . __init__ ( self , '<STR_LIT>' ) <EOL> self . NUM_NODES = <NUM_LIT:200> <EOL> self . NUM_SOURCES = <NUM_LIT:20> <EOL> self . P = <NUM_LIT> <EOL> def setup ( self ) : <EOL> self . ER_G = zn . Graph ( ) <EOL> for i in range ( self . NUM_NODES ) : <EOL> self . ER_G . add_node ( i ) <EOL> for i in range ( self . NUM_NODES ) : <EOL> for j in range ( i + <NUM_LIT:1> , self . NUM_NODES ) : <EOL> if random . random ( ) < self . P : <EOL> self . ER_G . add_edge_ ( i , j ) <EOL> def bm_zen ( self ) : <EOL> zn . all_pairs_shortest_path_length ( self . ER_G ) <EOL> def bm_zenopt ( self ) : <EOL> zn . all_pairs_shortest_path_length_ ( self . ER_G ) <EOL> def setup_networkx ( self ) : <EOL> self . nx_ER_G = nx . Graph ( ) <EOL> for i in self . ER_G . nodes_iter ( ) : <EOL> self . nx_ER_G . add_node ( i ) <EOL> for i , j in self . ER_G . edges_iter ( ) : <EOL> self . nx_ER_G . add_edge ( i , j ) <EOL> def bm_networkx ( self ) : <EOL> nx . all_pairs_shortest_path_length ( self . nx_ER_G ) <EOL> def setup_igraph ( self ) : <EOL> self . ig_ER_G = ig . Graph ( ) <EOL> self . ig_ER_G . add_vertices ( len ( self . ER_G ) ) <EOL> self . ig_ER_G . add_edges ( self . ER_G . edges ( ) ) <EOL> def bm_igraph ( self ) : <EOL> self . ig_ER_G . shortest_paths ( ) </s>
