You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/coloring.jl
+34-30Lines changed: 34 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -17,18 +17,18 @@ The vertices are colored in a greedy fashion, following the `order` supplied.
17
17
> [_What Color Is Your Jacobian? Graph Coloring for Computing Derivatives_](https://epubs.siam.org/doi/10.1137/S0036144504444711), Gebremedhin et al. (2005), Algorithm 3.2
@@ -76,15 +76,17 @@ If `postprocessing=true`, some colors might be replaced with `0` (the "neutral"
76
76
77
77
> [_New Acyclic and Star Coloring Algorithms with Application to Computing Hessians_](https://epubs.siam.org/doi/abs/10.1137/050639879), Gebremedhin et al. (2007), Algorithm 4.1
first_neighbor =fill((0, 0, 0), nv) # at first no neighbors have been encountered
86
-
treated =zeros(Int, nv)
87
-
star =Vector{Int}(undef, ne)
85
+
color =zeros(T, nv)
86
+
forbidden_colors =zeros(T, nv)
87
+
first_neighbor =fill((zero(T), zero(T), zero(T)), nv) # at first no neighbors have been encountered
88
+
treated =zeros(T, nv)
89
+
star =Vector{T}(undef, ne)
88
90
hub = Int[] # one hub for each star, including the trivial ones
89
91
vertices_in_order =vertices(g, order)
90
92
@@ -196,11 +198,11 @@ Encode a set of 2-colored stars resulting from the [`star_coloring`](@ref) algor
196
198
197
199
$TYPEDFIELDS
198
200
"""
199
-
struct StarSet
201
+
struct StarSet{T}
200
202
"a mapping from edges (pair of vertices) to their star index"
201
-
star::Vector{Int}
203
+
star::Vector{T}
202
204
"a mapping from star indices to their hub (undefined hubs for single-edge stars are the negative value of one of the vertices, picked arbitrarily)"
203
-
hub::Vector{Int}
205
+
hub::Vector{T}
204
206
end
205
207
206
208
"""
@@ -226,15 +228,17 @@ If `postprocessing=true`, some colors might be replaced with `0` (the "neutral"
226
228
227
229
> [_New Acyclic and Star Coloring Algorithms with Application to Computing Hessians_](https://epubs.siam.org/doi/abs/10.1137/050639879), Gebremedhin et al. (2007), Algorithm 3.1
Copy file name to clipboardExpand all lines: src/constant.jl
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ Indeed, for symmetric coloring problems, we need more than just the vector of co
14
14
15
15
- `partition::Symbol`: either `:row` or `:column`.
16
16
- `matrix_template::AbstractMatrix`: matrix for which the vector of colors was precomputed (the algorithm will only accept matrices of the exact same size).
17
-
- `color::Vector{Int}`: vector of integer colors, one for each row or column (depending on `partition`).
17
+
- `color::Vector{<:Integer}`: vector of integer colors, one for each row or column (depending on `partition`).
18
18
19
19
!!! warning
20
20
The second constructor (based on keyword arguments) is type-unstable.
@@ -222,7 +222,7 @@ The adjacency graph of a symmetric matrix `A ∈ ℝ^{n × n}` is `G(A) = (V, E)
222
222
223
223
> [_What Color Is Your Jacobian? SparsityPatternCSC Coloring for Computing Derivatives_](https://epubs.siam.org/doi/10.1137/S0036144504444711), Gebremedhin et al. (2005)
224
224
"""
225
-
struct AdjacencyGraph{T,has_diagonal}
225
+
struct AdjacencyGraph{T<:Integer,has_diagonal}
226
226
S::SparsityPatternCSC{T}
227
227
edge_to_index::Vector{T}
228
228
end
@@ -298,7 +298,7 @@ function has_neighbor(g::AdjacencyGraph, v::Integer, u::Integer)
@@ -338,7 +338,7 @@ When `symmetric_pattern` is `true`, this construction is more efficient.
338
338
339
339
> [_What Color Is Your Jacobian? SparsityPatternCSC Coloring for Computing Derivatives_](https://epubs.siam.org/doi/10.1137/S0036144504444711), Gebremedhin et al. (2005)
0 commit comments