Skip to content

Commit 9534ff3

Browse files
gdalleamontoison
authored andcommitted
Clearly separate AdjacencyGraph and BipartiteGraph from the underlying sparsity pattern
1 parent b274008 commit 9534ff3

10 files changed

Lines changed: 193 additions & 237 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
playground.jl
2+
13
*.json
24
*.json.tmp
35

docs/src/dev.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ The docstrings on this page describe internals, they are not part of the public
1010
## Graph storage
1111

1212
```@docs
13-
SparseMatrixColorings.Graph
13+
SparseMatrixColorings.SparsePatternCSC
14+
transpose
15+
SparseMatrixColorings.AdjacencyGraph
1416
SparseMatrixColorings.BipartiteGraph
1517
SparseMatrixColorings.vertices
1618
SparseMatrixColorings.neighbors
17-
SparseMatrixColorings.adjacency_graph
18-
SparseMatrixColorings.bipartite_graph
19-
transpose
2019
```
2120

2221
## Low-level coloring

src/coloring.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function partial_distance2_coloring!(
5454
end
5555

5656
"""
57-
star_coloring(g::Graph, order::AbstractOrder)
57+
star_coloring(g::AdjacencyGraph, order::AbstractOrder)
5858
5959
Compute a star coloring of all vertices in the adjacency graph `g` and return a tuple `(color, star_set)`, where
6060
@@ -67,14 +67,14 @@ The vertices are colored in a greedy fashion, following the `order` supplied.
6767
6868
# See also
6969
70-
- [`Graph`](@ref)
70+
- [`AdjacencyGraph`](@ref)
7171
- [`AbstractOrder`](@ref)
7272
7373
# References
7474
7575
> [_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
7676
"""
77-
function star_coloring(g::Graph{false}, order::AbstractOrder)
77+
function star_coloring(g::AdjacencyGraph, order::AbstractOrder)
7878
# Initialize data structures
7979
nv = nb_vertices(g)
8080
color = zeros(Int, nv)
@@ -157,7 +157,7 @@ function _treat!(
157157
treated::AbstractVector{<:Integer},
158158
forbidden_colors::AbstractVector{<:Integer},
159159
# not modified
160-
g::Graph,
160+
g::AdjacencyGraph,
161161
v::Integer,
162162
w::Integer,
163163
color::AbstractVector{<:Integer},
@@ -175,7 +175,7 @@ function _update_stars!(
175175
star::Dict{<:Tuple,<:Integer},
176176
hub::AbstractVector{<:Integer},
177177
# not modified
178-
g::Graph,
178+
g::AdjacencyGraph,
179179
v::Integer,
180180
color::AbstractVector{<:Integer},
181181
first_neighbor::AbstractVector{<:Tuple},
@@ -247,7 +247,7 @@ function symmetric_coefficient(
247247
end
248248

249249
"""
250-
acyclic_coloring(g::Graph, order::AbstractOrder)
250+
acyclic_coloring(g::AdjacencyGraph, order::AbstractOrder)
251251
252252
Compute an acyclic coloring of all vertices in the adjacency graph `g` and return a tuple `(color, tree_set)`, where
253253
@@ -260,17 +260,17 @@ The vertices are colored in a greedy fashion, following the `order` supplied.
260260
261261
# See also
262262
263-
- [`Graph`](@ref)
263+
- [`AdjacencyGraph`](@ref)
264264
- [`AbstractOrder`](@ref)
265265
266266
# References
267267
268268
> [_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
269269
"""
270-
function acyclic_coloring(g::Graph{false}, order::AbstractOrder)
270+
function acyclic_coloring(g::AdjacencyGraph, order::AbstractOrder)
271271
# Initialize data structures
272272
nv = nb_vertices(g)
273-
ne = nb_edges(g) ÷ 2 # symmetric sparse matrix with empty diagonal
273+
ne = nb_edges(g)
274274
color = zeros(Int, nv)
275275
forbidden_colors = zeros(Int, nv)
276276
first_neighbor = fill((0, 0), nv) # at first no neighbors have been encountered

0 commit comments

Comments
 (0)