Skip to content

Commit 140dfe3

Browse files
author
Avik Pal
committed
Don't restrict the input type of matrix2graph unnecessarily
1 parent 1435e0b commit 140dfe3

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseDiffTools"
22
uuid = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
33
authors = ["Pankaj Mishra <pankajmishra1511@gmail.com>", "Chris Rackauckas <contact@chrisrackauckas.com>"]
4-
version = "2.5.1"
4+
version = "2.5.2"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/coloring/matrix2graph.jl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ end
1616
"""
1717
_rows_by_cols(rows_index,cols_index)
1818
19-
Returns a vector of columns where each column contains
20-
a vector of its row indices.
19+
Returns a vector of columns where each column contains a vector of its row indices.
2120
"""
2221
function _rows_by_cols(rows_index, cols_index)
2322
return _cols_by_rows(cols_index, rows_index)
@@ -26,15 +25,14 @@ end
2625
"""
2726
matrix2graph(sparse_matrix, [partition_by_rows::Bool=true])
2827
29-
A utility function to generate a graph from input
30-
sparse matrix, columns are represented with vertices
31-
and 2 vertices are connected with an edge only if
32-
the two columns are mutually orthogonal.
28+
A utility function to generate a graph from input sparse matrix, columns are represented
29+
with vertices and 2 vertices are connected with an edge only if the two columns are mutually
30+
orthogonal.
3331
34-
Note that the sparsity pattern is defined by structural nonzeroes, ie includes
35-
explicitly stored zeros.
32+
Note that the sparsity pattern is defined by structural nonzeroes, ie includes explicitly
33+
stored zeros.
3634
"""
37-
function matrix2graph(sparse_matrix::SparseMatrixCSC{<:Number, Int},
35+
function matrix2graph(sparse_matrix::AbstractSparseMatrix{<:Number},
3836
partition_by_rows::Bool = true)
3937
(rows_index, cols_index, _) = findnz(sparse_matrix)
4038

@@ -43,7 +41,7 @@ function matrix2graph(sparse_matrix::SparseMatrixCSC{<:Number, Int},
4341

4442
num_vtx = partition_by_rows ? nrows : ncols
4543

46-
inner = SimpleGraph(num_vtx)
44+
inner = SimpleGraph{promote_type(eltype(rows_index), eltype(cols_index))}(num_vtx)
4745

4846
if partition_by_rows
4947
rows_by_cols = _rows_by_cols(rows_index, cols_index)

0 commit comments

Comments
 (0)