$ show GiulioRossetti/ndlib
NDlib is a Python library for modeling and simulating diffusion processes on complex networks, with a strong focus on epidemic compartment models and opinion dynamics. It provides a collection of built-in models (SIR, SEIR, voter model, bounded confidence, etc.), a flexible compartment-based composition system for building custom models, and a domain-specific language (NDQL) for defining models declaratively. The library also includes an interactive dashboard server for code-free experimentation, visualization modules (matplotlib and bokeh), and a sensitivity analysis runner via SALib. While the codebase demonstrates solid architectural patterns such as abstract base classes, configuration objects, and block schema registries, it suffers from significant technical drift: it retains Python 2 compatibility shims (six, future), uses outdated dependency versions, and has brittle test infrastructure. The dashboard and parser rely on dynamic code generation that is fragile. Overall, NDlib is a functional research-oriented library with reusable compartment and configuration patterns, but its maintenance has stalled, making it risky for new projects without substantial modernization.
The LLM identified 4 files worth highlighting for reuse:
Abstract base class for all compartments, defining the interface for status transitions in diffusion models. It enforces a pattern of status code registration, node/edge configuration validation, and iteration logic. This component is self-contained and could be extracted to build any discrete-state simulation on networks, demonstrating clean separation of concerns and validation patterns.
Implements high-level blocks (e.g., ExposureRate, OpinionCompromise, SeedSelection) that serve as reusable building blocks for composing custom diffusion models via NDQL. Each block encapsulates a specific transition logic and parameter schema. This pattern is reusable for any domain that needs a composable block library for simulation models, and it demonstrates how to bridge a DSL with Python implementations.
Central registry for block family metadata, used by the dashboard, parser, and code generator. It defines block names, descriptions, parameter schemas, and validation rules. This pattern ensures a single source of truth for block definitions across the system, and could be extracted to manage any plugin or component registry in a web application.
Configuration class that collects model parameters, node/edge attributes, and validation rules. It provides a fluent API (add_model_parameter, add_node_set_configuration) and collects errors as structured dicts. This pattern is reusable for any simulation or configuration-heavy application, demonstrating clean separation of configuration from execution logic.