-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSparseMatrixColoringsCliqueTreesExt.jl
More file actions
36 lines (26 loc) · 1.05 KB
/
SparseMatrixColoringsCliqueTreesExt.jl
File metadata and controls
36 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module SparseMatrixColoringsCliqueTreesExt
using CliqueTrees: CliqueTrees
using SparseArrays
using SparseMatrixColorings:
SparseMatrixColorings, AdjacencyGraph, BipartiteGraph, PerfectEliminationOrder, pattern
function SparseMatrixColorings.vertices(
g::AdjacencyGraph{T}, order::PerfectEliminationOrder
) where {T}
S = pattern(g)
# construct matrix with sparsity pattern S
M = SparseMatrixCSC{Bool,T}(size(S)..., S.colptr, rowvals(S), ones(Bool, nnz(S)))
# can also use alg=CliqueTrees.LexBFS()
order, _ = CliqueTrees.permutation(M; alg=CliqueTrees.MCS())
return reverse!(order)
end
function SparseMatrixColorings.vertices(
bg::BipartiteGraph{T}, ::Val{side}, order::PerfectEliminationOrder
) where {T,side}
S = pattern(bg, Val(side))
# construct matrix with sparsity pattern S
M = SparseMatrixCSC{Bool,T}(size(S)..., S.colptr, rowvals(S), ones(Bool, nnz(S)))
# can also use alg=CliqueTrees.LexBFS()
order, _ = CliqueTrees.permutation(M; alg=CliqueTrees.MCS())
return reverse!(order)
end
end # module