Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docstring to internal structs in Coloring #2560

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all 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
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
Loading