@@ -7,41 +7,37 @@ and 2 vertices are connected with an edge only if
7
7
the two columns are mutually orthogonal.
8
8
"""
9
9
function 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)
12
13
13
14
ncols = size (sparse_matrix, 2 )
14
15
nrows = size (sparse_matrix, 1 )
15
16
16
17
num_vtx = partition_by_rows ? nrows : ncols
17
18
18
19
inner = SimpleGraph (num_vtx)
19
- graph = VSafeGraph (inner)
20
20
21
21
if partition_by_rows
22
- for i = 1 : length (rows_index)
22
+ @inbounds for i in eachindex (rows_index)
23
23
cur_row = rows_index[i]
24
- for j = 1 : (i- 1 )
24
+ for j in 1 : (i- 1 )
25
25
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)
30
28
end
31
29
end
32
30
end
33
31
else
34
- for i = 1 : length (cols_index)
32
+ @inbounds for i in eachindex (cols_index)
35
33
cur_col = cols_index[i]
36
- for j = 1 : (i- 1 )
34
+ for j in 1 : (i- 1 )
37
35
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)
42
38
end
43
39
end
44
40
end
45
41
end
46
- return graph
42
+ return VSafeGraph (inner)
47
43
end
0 commit comments