@@ -7,41 +7,37 @@ and 2 vertices are connected with an edge only if
77the two columns are mutually orthogonal.
88"""
99function matrix2graph (sparse_matrix:: SparseMatrixCSC{<:Number, Int} , partition_by_rows:: Bool )
10- dropzeros (sparse_matrix)
11- (rows_index, cols_index, val) = findnz (sparse_matrix)
10+
11+ dropzeros! (sparse_matrix)
12+ (rows_index, cols_index, _) = findnz (sparse_matrix)
1213
1314 ncols = size (sparse_matrix, 2 )
1415 nrows = size (sparse_matrix, 1 )
1516
1617 num_vtx = partition_by_rows ? nrows : ncols
1718
1819 inner = SimpleGraph (num_vtx)
19- graph = VSafeGraph (inner)
2020
2121 if partition_by_rows
22- for i = 1 : length (rows_index)
22+ @inbounds for i in eachindex (rows_index)
2323 cur_row = rows_index[i]
24- for j = 1 : (i- 1 )
24+ for j in 1 : (i- 1 )
2525 next_row = rows_index[j]
26- if cur_row != next_row
27- if cols_index[i] == cols_index[j]
28- add_edge! (graph, cur_row, next_row)
29- end
26+ if cols_index[i] == cols_index[j] && cur_row != next_row
27+ add_edge! (inner, cur_row, next_row)
3028 end
3129 end
3230 end
3331 else
34- for i = 1 : length (cols_index)
32+ @inbounds for i in eachindex (cols_index)
3533 cur_col = cols_index[i]
36- for j = 1 : (i- 1 )
34+ for j in 1 : (i- 1 )
3735 next_col = cols_index[j]
38- if cur_col != next_col
39- if rows_index[i] == rows_index[j]
40- add_edge! (graph, cur_col, next_col)
41- end
36+ if rows_index[i] == rows_index[j] && cur_col != next_col
37+ add_edge! (inner, cur_col, next_col)
4238 end
4339 end
4440 end
4541 end
46- return graph
42+ return VSafeGraph (inner)
4743end
0 commit comments