CDlib

repository·master·Indexed 19 days ago

https://github.com/giuliorossetti/cdlib

A Python meta-library for community detection in complex networks. It provides a wide array of algorithms—including classical, modularity-based, random walk, spectral, overlapping, local, SBM, and deep learning approaches—along with clustering fitness functions, resemblance scores, and visualization facilities. CDlib is designed around networkx and provides an abstraction layer for igraph objects.

Tokens
20.1K
Snippets
48
Records
91
Agent score
64%

What's inside cdlib

  1. Overview of CDlib capabilities

    master

    CDlib is a Python software package designed for working with communities in complex networks. Its primary capabilities include:

    • Extracting: Running community detection algorithms on networks.
    • Comparing: Measuring similarities or differences between different community structures.
    • Evaluating: Assessing the quality or properties of detected communities.

    The library provides a standardized input/output interface for various community detection algorithms, many of which are inherited from existing specialized projects.

  2. Overview of CDlib

    master
    cdlib is a Python package designed for extracting, comparing, and evaluating communities within complex networks. It provides a standard programming interface for community discovery implementations, making it suitable for multidisciplinary applications in mathematics, physics, biology, computer science, and social sciences.
  3. Overview of the cdlib API structure

    master

    The cdlib library is organized into several specialized modules, each targeting a specific stage or type of community detection task. When building workflows, you can navigate the library using these core modules:

    • Algorithms: Core community detection algorithms.
    • Classes: High-level abstractions and data structures.
    • Temporal Clustering: Methods for detecting communities in dynamic/temporal networks.
    • Events: Detection and analysis of events within networks.
    • Evaluation: Metrics and methods to evaluate the quality of detected communities.
    • Validation: Methods to validate community structures.
    • Viz: Visualization tools for networks and communities.
    • Readwrite: Utilities for importing and exporting network and community data.
    • Utils: General helper functions.
  4. Generate synthetic static networks with ground truth communities

    master

    To evaluate community detection algorithms where topological ground truth is required, cdlib provides synthetic network generators. These generators create networks with planted community structures.

    For static networks, all generators in the cdlib.benchmark module return a tuple containing:

    1. A networkx.Graph object representing the generated network.
    2. A cdlib.NodeClustering object representing the ground truth community structure.

    Available static network generators include:

    • GRP
    • LFR
    • PP
    • RPG
    • SBM
    • XMark (for node-attributed static networks)
  5. Use synthetic benchmarks for community discovery

    master

    To facilitate standard evaluation tasks, cdlib provides synthetic network generators that include topological community ground truth annotations. These benchmarks are categorized by the type of community discovery being performed:

    • Static community discovery.
    • Dynamic community discovery.
    • Feature-rich (node-attributed) community discovery.

    These benchmarks allow you to test how well your algorithms identify communities against a known, mathematically generated ground truth.

  6. Access networks with annotated communities

    master

    For testing against real-world data, cdlib integrates well-known medium-size network datasets that come with ground-truth community annotations.

    Because these datasets are large, cdlib uses a specialized API to fetch them transparently from a dedicated remote repository. This allows you to evaluate topological partitions against semantic ground truths without manually managing large data files.

  7. Compare algorithms and parameters using grid_execution and pool

    master

    CDlib provides two primary ways to handle multiple instantiations of community detection:

    1. Varying parameters of a single algorithm: Use grid_execution to run the same method multiple times while varying its input parameters across a defined grid.
    2. Comparing multiple different algorithms: Use pool to manage and compare results from a collection of different community detection algorithms.
    # Conceptual usage pattern
    # Use grid_execution to vary parameters of one algorithm
    # Use pool to compare multiple different algorithms
  8. Understand the different types of Community Objects in CDlib

    master

    CDlib standardizes network community representations through several Clustering classes. Each class is designed to capture specific community characteristics. Depending on the algorithm used, CDlib outputs one of the following types:

    • NodeClustering: Represents node communities, either as crisp partitions (disjoint sets) or overlapping groups.
    • FuzzyNodeClustering: Represents overlapping node communities where each node has an explicit belonging score to a community.
    • BiNodeClustering: Used for clustering Bipartite graphs, representing class-homogeneous communities.
    • AttrNodeClustering: Used for clustering feature-rich (node-attributed) graphs.
    • EdgeClustering: Represents communities formed by edges.
    • TemporalClustering: Represents communities within Temporal Networks.
  9. How Temporal Trade-off dynamic community discovery works

    master

    Temporal Trade-off algorithms process network evolution iteratively. Unlike Instant Optimal approaches, they do not treat snapshots in isolation; instead, they use the network state and the communities identified in the previous step (or $n$ previous steps) to inform the community detection in the current step.

    The process follows an iterative pattern:

    1. Initialization: Find communities for the initial state of the network.
    2. Update: Find communities at step $t$ by using the graph at $t$ combined with information from past steps.

    This class of algorithms is designed for scenarios where the temporal continuity of communities is a core part of the discovery process.

  10. Understand the types of Static Community Discovery algorithms

    master

    CDlib provides a wide range of static community discovery algorithms. These are categorized by the type of partition they produce. When choosing an algorithm, identify which partition type matches your network and research goals:

    • Crisp partition: Hard clustering where each node belongs to exactly one community.
    • Overlapping clustering: Nodes can belong to multiple communities.
    • Fuzzy partition: Soft clustering where nodes have varying degrees of membership.
    • Bipartite clustering: Specifically designed for clustering bipartite networks.
    • Feature-rich (node attributed) clustering: Leverages both network topology and node features/attributes.
    • Antichains clustering in DAG: Specifically for directed acyclic graphs.
  11. Define parameter ranges using Parameter and BoolParameter

    master
    To automate the execution of community detection algorithms with varying inputs, you can define parameter ranges using Parameter (for numeric values) and BoolParameter (for boolean values). These objects are used within ensemble methods to specify the search space for algorithm inputs.
  12. Understand CDlib graph representation and performance

    master

    CDlib is designed to be agnostic to the data structure used to represent the network. All implemented algorithms accept igraph or networkx objects interchangeably.

    Key considerations for users:

    • Advantages: Easy integration of algorithms, standardized input/output, and zero-configuration (no need to reshape data).
    • Drawbacks:
      • Performance: Execution time and scalability depend on the original implementation of each algorithm.
      • Memory: Memory efficiency varies; some algorithms may have high consumption depending on the required structure.
      • Transformation overhead: Moving between different graph representations (e.g., networkx to igraph) involves a transformation time that is typically linear in the graph size.
    • Scalability: Each algorithm has a different maximum graph size it can handle; users should verify the limits of specific algorithms before running large-scale tasks.