Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
playground.jl

*.json
*.json.tmp

Expand Down
7 changes: 3 additions & 4 deletions docs/src/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ The docstrings on this page describe internals, they are not part of the public
## Graph storage

```@docs
SparseMatrixColorings.Graph
SparseMatrixColorings.SparsePatternCSC
transpose
SparseMatrixColorings.AdjacencyGraph
SparseMatrixColorings.BipartiteGraph
SparseMatrixColorings.vertices
SparseMatrixColorings.neighbors
SparseMatrixColorings.adjacency_graph
SparseMatrixColorings.bipartite_graph
transpose
```

## Low-level coloring
Expand Down
18 changes: 9 additions & 9 deletions src/coloring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function partial_distance2_coloring!(
end

"""
star_coloring(g::Graph, order::AbstractOrder)
star_coloring(g::AdjacencyGraph, order::AbstractOrder)

Compute a star coloring of all vertices in the adjacency graph `g` and return a tuple `(color, star_set)`, where

Expand All @@ -67,14 +67,14 @@ The vertices are colored in a greedy fashion, following the `order` supplied.

# See also

- [`Graph`](@ref)
- [`AdjacencyGraph`](@ref)
- [`AbstractOrder`](@ref)

# References

> [_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
"""
function star_coloring(g::Graph{false}, order::AbstractOrder)
function star_coloring(g::AdjacencyGraph, order::AbstractOrder)
# Initialize data structures
nv = nb_vertices(g)
color = zeros(Int, nv)
Expand Down Expand Up @@ -157,7 +157,7 @@ function _treat!(
treated::AbstractVector{<:Integer},
forbidden_colors::AbstractVector{<:Integer},
# not modified
g::Graph,
g::AdjacencyGraph,
v::Integer,
w::Integer,
color::AbstractVector{<:Integer},
Expand All @@ -175,7 +175,7 @@ function _update_stars!(
star::Dict{<:Tuple,<:Integer},
hub::AbstractVector{<:Integer},
# not modified
g::Graph,
g::AdjacencyGraph,
v::Integer,
color::AbstractVector{<:Integer},
first_neighbor::AbstractVector{<:Tuple},
Expand Down Expand Up @@ -247,7 +247,7 @@ function symmetric_coefficient(
end

"""
acyclic_coloring(g::Graph, order::AbstractOrder)
acyclic_coloring(g::AdjacencyGraph, order::AbstractOrder)

Compute an acyclic coloring of all vertices in the adjacency graph `g` and return a tuple `(color, tree_set)`, where

Expand All @@ -260,17 +260,17 @@ The vertices are colored in a greedy fashion, following the `order` supplied.

# See also

- [`Graph`](@ref)
- [`AdjacencyGraph`](@ref)
- [`AbstractOrder`](@ref)

# References

> [_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
"""
function acyclic_coloring(g::Graph{false}, order::AbstractOrder)
function acyclic_coloring(g::AdjacencyGraph, order::AbstractOrder)
# Initialize data structures
nv = nb_vertices(g)
ne = nb_edges(g) ÷ 2 # symmetric sparse matrix with empty diagonal
ne = nb_edges(g)
color = zeros(Int, nv)
forbidden_colors = zeros(Int, nv)
first_neighbor = fill((0, 0), nv) # at first no neighbors have been encountered
Expand Down
Loading