Skip to content

Commit b03cce6

Browse files
authored
[Coloring] fix docstrings (#2622)
1 parent 88c9776 commit b03cce6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Nonlinear/ReverseAD/Coloring/Coloring.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ include("topological_sort.jl")
1717
nnz::Int
1818
end
1919
20-
Represent the set `nzidx[1:nnz]` by additionally setting `empty[i]` to `true`
21-
for each element of the set for fast membership check.
20+
Represent the set `nzidx[1:nnz]` by additionally setting `empty[i]` to `false`
21+
for each element `i` of the set for fast membership check.
2222
"""
2323
mutable struct IndexedSet
2424
nzidx::Vector{Int}
@@ -44,6 +44,8 @@ function Base.empty!(v::IndexedSet)
4444
return v
4545
end
4646

47+
# Returns the maximum index that the set can contain,
48+
# not the cardinality of the set like `length(::Base.Set)`
4749
Base.length(v::IndexedSet) = length(v.nzidx)
4850

4951
function Base.resize!(v::IndexedSet, n::Integer)
@@ -75,8 +77,8 @@ end
7577
7678
Compact storage for an undirected graph. The number of nodes is given by
7779
`length(offsets) - 1`. The edges of node `u` are given by `edges[e]` for
78-
`e in edgeindex[offsets[u]:(offsets[u] - 1)]`. The neighbors are also
79-
stored at `adjlist[offsets[u]:(offsets[u] - 1)]`.
80+
`e in edgeindex[offsets[u]:(offsets[u+1] - 1)]`. The neighbors are also
81+
stored at `adjlist[offsets[u]:(offsets[u+1] - 1)]`.
8082
"""
8183
struct UndirectedGraph
8284
adjlist::Vector{Int}
@@ -473,7 +475,7 @@ function hessian_color_preprocess(
473475
push!(I, i)
474476
push!(J, j)
475477
end
476-
local_indices = sort!(seen_idx.nzidx[1:seen_idx.nnz])
478+
local_indices = sort!(collect(seen_idx))
477479
empty!(seen_idx)
478480
global_to_local_idx = seen_idx.nzidx # steal for storage
479481
for k in eachindex(local_indices)

0 commit comments

Comments
 (0)