Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ SparseArrays.nnz(S::SparsityPatternCSC) = length(S.rowval)
SparseArrays.rowvals(S::SparsityPatternCSC) = S.rowval
SparseArrays.nzrange(S::SparsityPatternCSC, j::Integer) = S.colptr[j]:(S.colptr[j + 1] - 1)

# Needed if using `coloring(::SparsityPatternCSC, ...)`
function Base.similar(A::SparsityPatternCSC, ::Type{T}) where {T}
return SparseArrays.SparseMatrixCSC(A.m, A.n, A.colptr, A.rowval, similar(A.rowval, T))
end

"""
transpose(S::SparsityPatternCSC)

Expand Down
16 changes: 16 additions & 0 deletions test/structured.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,19 @@ end;
test_structured_coloring_decompression(A)
end
end;

# See https://github.com/gdalle/SparseMatrixColorings.jl/pull/299
@testset "SparsityPatternCSC" begin
S = sparse([
0 0 1 1 0 1
1 0 0 0 1 0
0 1 0 0 1 0
0 1 1 0 0 0
])
P = SparseMatrixColorings.SparsityPatternCSC(S)
problem = ColoringProblem()
algo = GreedyColoringAlgorithm()
result = coloring(P, problem, algo)
B = compress(S, result)
@test decompress(B, result) isa SparseMatrixCSC{Int,Int}
end;
Loading