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.elemsFunction
elems(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.

source
HierarchicalHotNet.closepart!Function
closepart!(ptn::Partition) -> ptn

Finalize the last part of the partition and append the new empty part.

All subsequent calls to pushelem! will add elements into the new part.

source
HierarchicalHotNet.repeat!Function
repeat!(ptn::Partition, n::Integer) -> ptn

Repeat 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]
source
HierarchicalHotNet.reset!Function
reset!(p::IndicesPartition, n::Integer=nelems(p); nparts::Integer=n) -> p

Resets 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]].

source

Matrix utilities

HierarchicalHotNet.condenseFunction
condense(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 to false: 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).
source
HierarchicalHotNet.condense!Function
condense!(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 to false: 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).
source

Object pools

Set of utilities for managing object pools to reduce the GC stress.

HierarchicalHotNet.borrow!Function
borrow!(pool::ObjectPool{T}) where T -> T

Gets an object from the pool. The returned object should be returned back to the pool using release!().

source
borrow!(pool::ArrayPool{T}, len::Integer = 0) where T -> T

Gets an array of specific size from the pool. The returned array should be returned back to the pool using release!().

source
HierarchicalHotNet.release!Function
release!(pool::ObjectPool{T}, obj::T) where T

Releases an object acquired by borrow!() back into the pool.

source
release!(pool::ArrayPool{T}, arr::Array{T}) where T

Releases an array returned by borrow!() back into the pool.

source

Other

HierarchicalHotNet.hilbertorderFunction
hilbertorder(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.

source