Partitions
Partition type provides an efficient container for storing multiple vectors of elements. The advantage over Vector{Vector{T}} is that internally it uses single Vector{T} to store the elements of all of its parts. The disadvantage is that it doesn't support adding or removing elements to/from arbitrary part, only the last part could be modified. Partition supports iterator interface for iterating over its parts as well as parts indexing and filter! for elements filtering.
HierarchicalHotNet.AbstractPartition — TypeBase class for partitions of elements of type T.
HierarchicalHotNet.Partition — TypeEfficiently stores the partition of a vector of elements of type T into disjoint sets.
Supports iterator interface.
HierarchicalHotNet.PartitionPart — TypeThe type of parts returned by Partition{T}
HierarchicalHotNet.nelems — Functionnelems(ptn::AbstractPartition)Total number of elements in the partition.
HierarchicalHotNet.elems — Functionelems(ptn::Partition{T}) where T -> Vector{T}Vector of elements in the partition.
Rerturns the vectors as they are stored in ptn: the elements are ordered by their parts (elements from the first part come first etc) and maintain the same order as within each part.
HierarchicalHotNet.nparts — Functionnelems(ptn::AbstractPartition) -> IntNumber of parts in the partition.
Same as length(ptn).
HierarchicalHotNet.partrange — Functionpartrange(ptn::Partition, i::Integer) -> UnitRange{Int}Range of indices associated with i-th part.
HierarchicalHotNet.partlength — Functionpartlength(ptn::Partition, i::Integer) -> IntNumber of elements in i-th part.
HierarchicalHotNet.ispartempty — Functionispartempty(ptn::Partition, i::Integer) -> BoolWhether i-th part is empty.
HierarchicalHotNet.pushelem! — Functionpushelem!(ptn::Partition, el) -> ptnPush the element into the last part of partition.
HierarchicalHotNet.closepart! — Functionclosepart!(ptn::Partition) -> ptnFinalize the last part of the partition and append the new empty part.
All subsequent calls to pushelem! will add elements into the new part.
HierarchicalHotNet.repeat! — Functionrepeat!(ptn::Partition, n::Integer) -> ptnRepeat the parts of ptn n times.
julia> using HierarchicalHotNet
julia> ptn = HierarchicalHotNet.IndicesPartition(5, nparts=1)
1-element HierarchicalHotNet.Partition{Int64}:
[1, 2, 3, 4, 5]
julia> HierarchicalHotNet.repeat!(ptn, 3)
3-element HierarchicalHotNet.Partition{Int64}:
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]HierarchicalHotNet.IndicesPartition — TypePartition of an integer vector
HierarchicalHotNet.reset! — Functionreset!(p::IndicesPartition, n::Integer=nelems(p); nparts::Integer=n) -> pResets the integer partition p.
If nparts == 1, the partition is reset into [[1, 2, 3, ..., n]]. If n == nparts, sets the partition to [[1], [2], [3], ..., [n]].
Matrix utilities
HierarchicalHotNet.condense — Functioncondense(A::AbstractMatrix{T}, node_groups::AbstractPartition,
[test::EdgeTest], [zerodiag::Bool]) where T -> Matrix{T}
condense(A::AbstractMatrix{T}, row_groups::AbstractPartition, col_groups::AbstractPartition,
[test::EdgeTest], [zerodiag::Bool]) where T -> Matrix{T}"Condenses" the matrix A by aggregating the values in the blocks of its elements defined by row_groups and col_groups.
Arguments
rev::Bool, defaults tofalse: if false, the aggregated value is the maximal value of the block (i.e. the edge with the highest weight). Otherwise, it's the minimal value (the edge with the smallest weight).
HierarchicalHotNet.condense! — Functioncondense!(B::AbstractMatrix{T}, A::AbstractMatrix{T},
node_groups::AbstractPartition,
test::EdgeTest{T} = EdgeTest{T}()) where T -> Matrix{T}"Condenses" the matrix A by aggregating the values in the blocks of its elements defined by row_groups and col_groups.
Arguments
rev::Bool, defaults tofalse: if false, the aggregated value is the maximal value of the block (i.e. the edge with the highest weight). Otherwise, it's the minimal value (the edge with the smallest weight).
Object pools
Set of utilities for managing object pools to reduce the GC stress.
HierarchicalHotNet.ObjectPool — TypeHelps to maintain the pool of reusable objects and reduce the burden on garbage collection.
HierarchicalHotNet.ArrayPool — TypeAlias for ObjectPool for arrays.
HierarchicalHotNet.NoopObjectPool — TypeFake array pool that just constructs arrays.
HierarchicalHotNet.borrow! — Functionborrow!(pool::ObjectPool{T}) where T -> TGets an object from the pool. The returned object should be returned back to the pool using release!().
borrow!(pool::ArrayPool{T}, len::Integer = 0) where T -> TGets an array of specific size from the pool. The returned array should be returned back to the pool using release!().
HierarchicalHotNet.release! — Functionrelease!(pool::ObjectPool{T}, obj::T) where TReleases an object acquired by borrow!() back into the pool.
release!(pool::ArrayPool{T}, arr::Array{T}) where TReleases an array returned by borrow!() back into the pool.
HierarchicalHotNet.ObjectPools — TypePool of object pools. Manages ObjectPool objects for different types.
Other
HierarchicalHotNet.hilbertorder — Functionhilbertorder(i::Integer, j::Integer, n::Integer)Get the index of the point (i, j) on the Hilbert curve that passes through the points of n×n grid, where n is some power of 2.