Options
All
  • Public
  • Public/Protected
  • All
Menu

Leiden algorithm.

The Leiden algorithm consists of three phases:

  1. local moving of nodes between clusters,
  2. refinement of the clusters,
  3. aggregation of the network based on the refined clusters, using the non-refined clusters to create an initial clustering for the aggregate network.

These phases are repeated until no further improvements can be made. By default, local moving of nodes is performed using the FastLocalMovingAlgorithm.

Hierarchy

Index

Properties

DEFAULT_RESOLUTION: number = 1

Default resolution parameter.

DEFAULT_N_ITERATIONS: number = 1

Default number of iterations.

DEFAULT_RANDOMNESS: number = LocalMergingAlgorithm.DEFAULT_RANDOMNESS

Default randomness parameter.

resolution: number

Resolution parameter.

nIterations: number

Number of iterations.

randomness: number

Randomness parameter.

localMovingAlgorithm: IncrementalCPMClusteringAlgorithm

Local moving algorithm.

random: Random

Random number generator.

Methods

  • getResolution(): number
  • Calculates the quality of a clustering using the CPM quality function.

    The CPM quality function is given by

    1 / (2 * m) * sum(d(c[i], c[j]) * (a[i][j] - resolution * n[i] *
    n[j])),

    where a[i][j] is the weight of the edge between nodes i and j, n[i] is the weight of node i, m is the total edge weight, and resolution is the resolutionparameter. The function d(c[i], c[j]) equals 1 if nodes i and j belong to the same cluster and 0 otherwise. The sum is taken over all pairs of nodes i and j.

    Modularity can be expressed in terms of CPM by setting n[i] equal to the total weight of the edges between node i and its neighbors and by rescaling the resolution parameter by 2 * m.

    Parameters

    Returns number

    Quality of the clustering

  • Removes a cluster from a clustering by merging the cluster with another cluster. If a cluster has no connections with other clusters, it cannot be removed.

    Parameters

    • network: Network

      Network

    • clustering: Clustering

      Clustering

    • cluster: number

      Cluster to be removed

    Returns number

    Cluster with which the cluster to be removed has been merged, or -1 if the cluster could not be removed

  • removeSmallClustersBasedOnNNodes(network: Network, clustering: Clustering, minNNodesPerCluster: number): boolean
  • removeSmallClustersBasedOnWeight(network: Network, clustering: Clustering, minClusterWeight: number): boolean
  • Removes small clusters from a clustering. Clusters are merged until each cluster has at least a certain minimum total node weight.

    The total node weight of a cluster equals the sum of the weights of the nodes belonging to the cluster.

    Parameters

    • network: Network

      Network

    • clustering: Clustering

      Clustering

    • minClusterWeight: number

      Minimum total node weight of a cluster

    Returns boolean

    Boolean indicating whether any clusters have been removed

  • initializeBasedOnResolution(resolution: number): void
  • initializeBasedOnResolutionAndNIterations(resolution: number, nIterations: number): void
  • getNIterations(): number
  • setNIterations(nIterations: number): void
  • initializeBasedOnRandom(random: Random): void
  • initializeBasedOnResolutionAndNIterationsAndRandomnessAndRandom(resolution: number, nIterations: number, randomness: number, random: Random): void
  • Initializes a Leiden algorithm for a specified resolution parameter, number of iterations, and randomness parameter.

    Parameters

    • resolution: number

      Resolution parameter

    • nIterations: number

      Number of iterations

    • randomness: number

      Randomness parameter

    • random: Random

      Random number generator

    Returns void

  • initializeBasedOnResolutionAndNIterationsAndRandomnessAndLocalMovingAlgorithmAndRandom(resolution: number, nIterations: number, randomness: number, localMovingAlgorithm: IncrementalCPMClusteringAlgorithm, random: Random): void
  • Initializes a Leiden algorithm for a specified resolution parameter, number of iterations, randomness parameter, and local moving algorithm.

    Parameters

    • resolution: number

      Resolution parameter

    • nIterations: number

      Number of iterations

    • randomness: number

      Randomness parameter

    • localMovingAlgorithm: IncrementalCPMClusteringAlgorithm

      Local moving algorithm

    • random: Random

      Random number generator

    Returns void

  • getRandomness(): number
  • setResolution(resolution: number): void
  • setRandomness(randomness: number): void
  • Sets the randomness parameter.

    Parameters

    • randomness: number

      Randomness parameter

    Returns void

  • Improves a clustering by performing one iteration of the Leiden algorithm.

    The Leiden algorithm consists of three phases:

    1. local moving of nodes between clusters,
    2. refinement of the clusters,
    3. aggregation of the network based on the refined clusters, using the non-refined clusters to create an initial clustering for the aggregate network.

    These phases are repeated until no further improvements can be made.

    Parameters

    Returns boolean

    Boolean indicating whether the clustering has been improved

Constructors

Generated using TypeDoc