Skip to content

Commit e8f3fbc

Browse files
committed
Improve the docstring of acyclic_coloring
1 parent 9f134db commit e8f3fbc

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

src/coloring.jl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ The vertices are colored in a greedy fashion, following the `order` supplied.
7676
"""
7777
function star_coloring(g::Graph, order::AbstractOrder)
7878
# Initialize data structures
79-
nv = length(g)
80-
color = zeros(Int, nv)
81-
forbidden_colors = zeros(Int, nv)
82-
first_neighbor = fill((0, 0), nv) # at first no neighbors have been encountered
83-
treated = zeros(Int, nv)
79+
nvertices = length(g)
80+
color = zeros(Int, nvertices)
81+
forbidden_colors = zeros(Int, nvertices)
82+
first_neighbor = fill((0, 0), nvertices) # at first no neighbors have been encountered
83+
treated = zeros(Int, nvertices)
8484
star = Dict{Tuple{Int,Int},Int}()
8585
hub = Int[]
8686
vertices_in_order = vertices(g, order)
@@ -263,7 +263,10 @@ end
263263
"""
264264
acyclic_coloring(g::Graph, order::AbstractOrder)
265265
266-
Compute an acyclic coloring of all vertices in the adjacency graph `g` and return a vector of integer colors.
266+
Compute an acyclic coloring of all vertices in the adjacency graph `g` and return a tuple `(color, tree_set)`, where
267+
268+
- `color` is the vector of integer colors
269+
- `tree_set` is a [`TreeSet`](@ref) encoding the set of 2-colored trees
267270
268271
An _acyclic coloring_ is a distance-1 coloring with the further restriction that every cycle uses at least 3 colors.
269272
@@ -280,12 +283,12 @@ The vertices are colored in a greedy fashion, following the `order` supplied.
280283
"""
281284
function acyclic_coloring(g::Graph, order::AbstractOrder)
282285
# Initialize data structures
283-
nv = length(g)
284-
ne = nnz(g) ÷ 2 # symmetric sparse matrix with empty diagonal
285-
color = zeros(Int, nv)
286-
forbidden_colors = zeros(Int, nv)
287-
first_neighbor = fill((0, 0), nv) # at first no neighbors have been encountered
288-
first_visit_to_tree = fill((0, 0), ne)
286+
nvertices = length(g)
287+
nedges = nnz(g) ÷ 2 # symmetric sparse matrix with empty diagonal
288+
color = zeros(Int, nvertices)
289+
forbidden_colors = zeros(Int, nvertices)
290+
first_neighbor = fill((0, 0), nvertices) # at first no neighbors have been encountered
291+
first_visit_to_tree = fill((0, 0), nedges)
289292
forest = DisjointSets{Tuple{Int,Int}}()
290293
vertices_in_order = vertices(g, order)
291294

0 commit comments

Comments
 (0)