@@ -40,36 +40,21 @@ def floyd_warshall(G, weight="weight", blocking_factor=None):
40
40
A = _adjacency_matrix (G , weight , nodelist , undirected )
41
41
n = G .number_of_nodes ()
42
42
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
+
50
45
if blocking_factor is None :
51
46
blocking_factor , is_prime = _find_nearest_divisor (n , total_cores )
52
47
no_of_primary = n // blocking_factor
53
48
54
- print (
55
- "blocking factor: " ,
56
- blocking_factor ,
57
- " number of block: " ,
58
- no_of_primary ,
59
- " number of core: " ,
60
- total_cores ,
61
- )
62
49
for primary_block in range (no_of_primary ):
63
50
k_start = (primary_block * n ) // no_of_primary
64
51
k_end = k_start + (n // no_of_primary ) - 1
65
52
if is_prime and primary_block == no_of_primary - 1 :
66
53
k_end = k_end + (n % no_of_primary )
67
54
k = (k_start , k_end )
68
55
# Phase 1: Compute Primary block
69
- # print("\n\niteration:",primary_block,"\n\n")
70
56
# Execute Normal floyd warshall for the primary block submatrix
71
57
_partial_floyd_warshall_numpy (A , k , k , k )
72
- # print("After phase 1 - it",primary_block,":\n",A)
73
58
# Phase 2: Compute Cross block
74
59
75
60
params = []
@@ -87,8 +72,7 @@ def floyd_warshall(G, weight="weight", blocking_factor=None):
87
72
Parallel (n_jobs = (no_of_primary - 1 ) * 2 , require = "sharedmem" )(
88
73
delayed (_partial_floyd_warshall_numpy )(A , k , i , j ) for (i , j ) in params
89
74
)
90
- # print("phase 2, coordinate", params)
91
- # print("After phase 2 - it",primary_block,":\n",A)
75
+
92
76
# Phase 3: Compute remaining
93
77
params .clear ()
94
78
for block_i in range (no_of_primary ):
@@ -106,9 +90,6 @@ def floyd_warshall(G, weight="weight", blocking_factor=None):
106
90
Parallel (n_jobs = (no_of_primary - 1 ) ** 2 , require = "sharedmem" )(
107
91
delayed (_partial_floyd_warshall_numpy )(A , k , i , j ) for (i , j ) in params
108
92
)
109
- # print("phase 3, coordinate", params)
110
- # print("After phase 3 - it",primary_block,":\n",A)
111
- # print("Matrice di adiacenza \n", A)
112
93
dist = _matrix_to_dict (A , nodelist )
113
94
114
95
return dist
0 commit comments