Skip to content

Commit f2d358f

Browse files
committed
Merge remote-tracking branch 'origin/main' into gd/structured3
2 parents ee82518 + c28490d commit f2d358f

6 files changed

Lines changed: 54 additions & 2 deletions

File tree

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseMatrixColorings"
22
uuid = "0a514795-09f3-496d-8182-132a7b665d35"
33
authors = ["Guillaume Dalle", "Alexis Montoison"]
4-
version = "0.4.4"
4+
version = "0.4.6"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -31,6 +31,7 @@ Compat = "3.46,4.2"
3131
DataStructures = "0.18"
3232
DocStringExtensions = "0.8,0.9"
3333
LinearAlgebra = "<0.0.1, 1"
34+
DocStringExtensions = "0.8,0.9"
3435
Random = "<0.0.1, 1"
3536
Requires = "1.3.0"
3637
SparseArrays = "<0.0.1, 1"

src/SparseMatrixColorings.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ include("result.jl")
5252
include("matrices.jl")
5353
include("interface.jl")
5454
include("constant.jl")
55+
include("adtypes.jl")
5556
include("decompression.jl")
5657
include("structured.jl")
5758
include("check.jl")

src/adtypes.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function coloring(
2+
A::AbstractMatrix,
3+
::ColoringProblem{:nonsymmetric,:column},
4+
algo::ADTypes.NoColoringAlgorithm;
5+
kwargs...,
6+
)
7+
bg = BipartiteGraph(A)
8+
color = convert(Vector{Int}, ADTypes.column_coloring(A, algo))
9+
return ColumnColoringResult(A, bg, color)
10+
end
11+
12+
function coloring(
13+
A::AbstractMatrix,
14+
::ColoringProblem{:nonsymmetric,:row},
15+
algo::ADTypes.NoColoringAlgorithm;
16+
kwargs...,
17+
)
18+
bg = BipartiteGraph(A)
19+
color = convert(Vector{Int}, ADTypes.row_coloring(A, algo))
20+
return RowColoringResult(A, bg, color)
21+
end

src/coloring.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ function symmetric_coefficient(
240240
if h == j
241241
# i is the spoke
242242
return i, color[h]
243-
elseif h == i
243+
else
244244
# j is the spoke
245245
return j, color[h]
246246
end

test/adtypes.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using ADTypes: ADTypes
2+
using SparseArrays
3+
using SparseMatrixColorings
4+
using Test
5+
6+
@testset "Column coloring" begin
7+
problem = ColoringProblem(; structure=:nonsymmetric, partition=:column)
8+
algo = ADTypes.NoColoringAlgorithm()
9+
A = sprand(10, 20, 0.1)
10+
result = coloring(A, problem, algo)
11+
B = compress(A, result)
12+
@test size(B) == size(A)
13+
@test column_colors(result) == ADTypes.column_coloring(A, algo)
14+
@test decompress(B, result) == A
15+
end
16+
17+
@testset "Row coloring" begin
18+
problem = ColoringProblem(; structure=:nonsymmetric, partition=:row)
19+
algo = ADTypes.NoColoringAlgorithm()
20+
A = sprand(10, 20, 0.1)
21+
result = coloring(A, problem, algo)
22+
B = compress(A, result)
23+
@test size(B) == size(A)
24+
@test row_colors(result) == ADTypes.row_coloring(A, algo)
25+
@test decompress(B, result) == A
26+
end

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ include("utils.jl")
4545
@testset "Constant coloring" begin
4646
include("constant.jl")
4747
end
48+
@testset "ADTypes coloring algorithms" begin
49+
include("adtypes.jl")
50+
end
4851
end
4952
@testset verbose = true "Correctness" begin
5053
@testset "Small instances" begin

0 commit comments

Comments
 (0)