Arcana.Graph.CommunityDetector.Leiden (Arcana v1.2.0)

View Source

Leiden algorithm implementation for community detection.

Uses the ExLeiden library to detect communities in entity graphs. The Leiden algorithm is a refinement of the Louvain algorithm that guarantees well-connected communities.

Usage

detector = {Arcana.Graph.CommunityDetector.Leiden, resolution: 1.0}
{:ok, communities} = CommunityDetector.detect(detector, entities, relationships)

Options

  • :resolution - Controls community granularity (default: 1.0) Higher values produce smaller communities
  • :max_level - Maximum hierarchy levels (default: 3)

Summary

Functions

Converts relationships to weighted edge tuples for ExLeiden.

Functions

to_edges(entity_ids, relationships)

@spec to_edges([String.t()], [map()]) :: [{String.t(), String.t(), number()}]

Converts relationships to weighted edge tuples for ExLeiden.

Filters out relationships that reference unknown entities and defaults missing strength values to 1.

Examples

iex> to_edges(["a", "b"], [%{source_id: "a", target_id: "b", strength: 5}])
[{"a", "b", 5}]