Skip to content

Commit

Permalink
Add docstring to internal structs in Coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Oct 17, 2024
1 parent dc71c13 commit bccdf2c
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/Nonlinear/ReverseAD/Coloring/Coloring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ import DataStructures

include("topological_sort.jl")

# indexed sparse set of integers
"""
mutable struct IndexedSet
nzidx::Vector{Int}
empty::BitVector
nnz::Int
end
Represent the set `nzidx[1:nnz]` by additionally setting `empty[i]` to `true`
for each element of the set for fast membership check.
"""
mutable struct IndexedSet
nzidx::Vector{Int}
empty::BitVector
Expand Down Expand Up @@ -56,8 +65,19 @@ function Base.union!(v::IndexedSet, s)
return
end

# compact storage for an undirected graph
# neighbors of vertex i start at adjlist[offsets[i]]
"""
struct UndirectedGraph
adjlist::Vector{Int}
edgeindex::Vector{Int}
offsets::Vector{Int}
edges::Vector{Tuple{Int,Int}}
end
Compact storage for an undirected graph. The number of nodes is given by
`length(offsets) - 1`. The edges of node `u` are given by `edges[e]` for
`e in edgeindex[offsets[u]:(offsets[u] - 1)]`. The neighbors are also
stored at `adjlist[offsets[u]:(offsets[u] - 1)]`.
"""
struct UndirectedGraph
adjlist::Vector{Int}
edgeindex::Vector{Int} # corresponding edge number, indexed as adjlist
Expand Down

0 comments on commit bccdf2c

Please sign in to comment.