Hierarchical community structure from algorithms like Louvain, Walktrap, Leiden.
A dendrogram represents multiple levels of community structure, from fine-grained (many small communities) to coarse-grained (few large communities).
Fields
levels- List of community partitions, ordered from finest to coarsestmerge_order- Sequence of community merges (optional)metadata- Optional metadata (algorithm name, modularity scores, etc.)
Examples
iex> level1 = Yog.Community.Result.new(%{1 => 0, 2 => 0, 3 => 1, 4 => 1})
iex> level2 = Yog.Community.Result.new(%{1 => 0, 2 => 0, 3 => 0, 4 => 0})
iex> dend = Yog.Community.Dendrogram.new([level1, level2])
iex> Yog.Community.Dendrogram.finest(dend).num_communities
2
iex> Yog.Community.Dendrogram.coarsest(dend).num_communities
1
Summary
Functions
Get partition with approximately n communities.
Get the coarsest partition (fewest communities).
Get the finest partition (most communities).
Backward compatibility: convert from legacy map format.
Get partition at a specific level index.
Creates a new dendrogram from a list of community levels.
Creates a new dendrogram with merge order tracking.
Get the number of hierarchical levels.
Convert to legacy map format.
Types
@type t() :: %Yog.Community.Dendrogram{ levels: [Yog.Community.Result.t()], merge_order: [{non_neg_integer(), non_neg_integer()}], metadata: map() }
Functions
@spec at_level(t(), non_neg_integer()) :: Yog.Community.Result.t() | nil
Get partition with approximately n communities.
Returns the first level with <= n communities.
@spec coarsest(t()) :: Yog.Community.Result.t()
Get the coarsest partition (fewest communities).
@spec finest(t()) :: Yog.Community.Result.t()
Get the finest partition (most communities).
Backward compatibility: convert from legacy map format.
@spec get_level(t(), non_neg_integer()) :: Yog.Community.Result.t() | nil
Get partition at a specific level index.
@spec new([Yog.Community.Result.t()]) :: t()
Creates a new dendrogram from a list of community levels.
@spec new([Yog.Community.Result.t()], [{non_neg_integer(), non_neg_integer()}]) :: t()
Creates a new dendrogram with merge order tracking.
@spec num_levels(t()) :: non_neg_integer()
Get the number of hierarchical levels.
Convert to legacy map format.