@@ -40,36 +40,21 @@ def floyd_warshall(G, weight="weight", blocking_factor=None):
4040 A = _adjacency_matrix (G , weight , nodelist , undirected )
4141 n = G .number_of_nodes ()
4242
43- total_cores = nxp .cpu_count ()
44- print (
45- "number of nodes: " ,
46- n ,
47- " number of core: " ,
48- total_cores ,
49- )
43+ total_cores = nxp .get_n_jobs ()
44+
5045 if blocking_factor is None :
5146 blocking_factor , is_prime = _find_nearest_divisor (n , total_cores )
5247 no_of_primary = n // blocking_factor
5348
54- print (
55- "blocking factor: " ,
56- blocking_factor ,
57- " number of block: " ,
58- no_of_primary ,
59- " number of core: " ,
60- total_cores ,
61- )
6249 for primary_block in range (no_of_primary ):
6350 k_start = (primary_block * n ) // no_of_primary
6451 k_end = k_start + (n // no_of_primary ) - 1
6552 if is_prime and primary_block == no_of_primary - 1 :
6653 k_end = k_end + (n % no_of_primary )
6754 k = (k_start , k_end )
6855 # Phase 1: Compute Primary block
69- # print("\n\niteration:",primary_block,"\n\n")
7056 # Execute Normal floyd warshall for the primary block submatrix
7157 _partial_floyd_warshall_numpy (A , k , k , k )
72- # print("After phase 1 - it",primary_block,":\n",A)
7358 # Phase 2: Compute Cross block
7459
7560 params = []
@@ -87,8 +72,7 @@ def floyd_warshall(G, weight="weight", blocking_factor=None):
8772 Parallel (n_jobs = (no_of_primary - 1 ) * 2 , require = "sharedmem" )(
8873 delayed (_partial_floyd_warshall_numpy )(A , k , i , j ) for (i , j ) in params
8974 )
90- # print("phase 2, coordinate", params)
91- # print("After phase 2 - it",primary_block,":\n",A)
75+
9276 # Phase 3: Compute remaining
9377 params .clear ()
9478 for block_i in range (no_of_primary ):
@@ -106,9 +90,6 @@ def floyd_warshall(G, weight="weight", blocking_factor=None):
10690 Parallel (n_jobs = (no_of_primary - 1 ) ** 2 , require = "sharedmem" )(
10791 delayed (_partial_floyd_warshall_numpy )(A , k , i , j ) for (i , j ) in params
10892 )
109- # print("phase 3, coordinate", params)
110- # print("After phase 3 - it",primary_block,":\n",A)
111- # print("Matrice di adiacenza \n", A)
11293 dist = _matrix_to_dict (A , nodelist )
11394
11495 return dist
0 commit comments