yog/community/fluid_communities

Asynchronous Fluid Communities detection algorithm.

This algorithm is based on the simple idea of fluids interacting and expanding in a graph environment. It is unique in that it allows specifying exactly the number of communities k to find.

The algorithm starts with k randomly placed fluids (seeds). Each fluid has a density that decreases as the community grows. Nodes iteratively update their community to match the fluid with the highest density in their neighborhood. The process completes when no node changes its community.

Example

import yog/community/fluid_communities

// Find exactly 4 communities
let options = fluid_communities.FluidOptions(
  target_communities: 4,
  max_iterations: 100,
  seed: Some(42)
)
let communities = fluid_communities.detect_with_options(graph, options)

References

Types

Options for the Fluid Communities algorithm.

pub type FluidOptions {
  FluidOptions(
    target_communities: Int,
    max_iterations: Int,
    seed: option.Option(Int),
  )
}

Constructors

  • FluidOptions(
      target_communities: Int,
      max_iterations: Int,
      seed: option.Option(Int),
    )

    Arguments

    target_communities

    Exact number of communities to partition the graph into.

    max_iterations

    Maximum number of propagation iterations.

    seed

    Seed for the random number generator (vital for consistent results due to random processing order and seed selection).

Values

pub fn default_options() -> FluidOptions

Default options: target 2 communities, max 100 iterations, random seed.

pub fn detect(graph: model.Graph(n, e)) -> community.Communities

Detects k communities on an unweighted graph. Default k = 2.

pub fn detect_with_options(
  graph: model.Graph(n, e),
  options: FluidOptions,
) -> community.Communities

Detects communities using specific options.

pub fn detect_with_weights(
  graph: model.Graph(n, e),
  options: FluidOptions,
  weight_fn: fn(e) -> Float,
) -> community.Communities

Detects communities using specific options and a given weight function.

Search Document