Yog.Community.Dendrogram (YogEx v0.97.0)

Copy Markdown View Source

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 coarsest
  • merge_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

t()

@type t() :: %Yog.Community.Dendrogram{
  levels: [Yog.Community.Result.t()],
  merge_order: [{non_neg_integer(), non_neg_integer()}],
  metadata: map()
}

Functions

at_level(dendrogram, n)

@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.

coarsest(dendrogram)

@spec coarsest(t()) :: Yog.Community.Result.t()

Get the coarsest partition (fewest communities).

finest(dendrogram)

@spec finest(t()) :: Yog.Community.Result.t()

Get the finest partition (most communities).

from_map(map)

@spec from_map(map()) :: t()

Backward compatibility: convert from legacy map format.

get_level(dendrogram, index)

@spec get_level(t(), non_neg_integer()) :: Yog.Community.Result.t() | nil

Get partition at a specific level index.

new(levels)

@spec new([Yog.Community.Result.t()]) :: t()

Creates a new dendrogram from a list of community levels.

new(levels, merge_order)

Creates a new dendrogram with merge order tracking.

num_levels(dendrogram)

@spec num_levels(t()) :: non_neg_integer()

Get the number of hierarchical levels.

to_map(dendrogram)

@spec to_map(t()) :: map()

Convert to legacy map format.