Metadata-Version: 2.4
Name: dynamic-multiplex
Version: 1.1.0
Summary: Multiplex temporal community detection with customizable interlayer coupling
Author-email: Jared Edgerton <jared.edgerton@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Jared Edgerton
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/jfedgerton/dynamic_multiplex
Project-URL: Repository, https://github.com/jfedgerton/dynamic_multiplex
Project-URL: Issues, https://github.com/jfedgerton/dynamic_multiplex/issues
Keywords: community detection,multiplex networks,temporal networks,louvain,leiden
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: networkx>=3.0
Requires-Dist: scipy>=1.7
Provides-Extra: louvain
Requires-Dist: python-louvain>=0.16; extra == "louvain"
Provides-Extra: leiden
Requires-Dist: python-igraph>=0.11; extra == "leiden"
Requires-Dist: leidenalg>=0.10; extra == "leiden"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Dynamic: license-file

# dynamic_multiplex (Python)

`dynamic_multiplex` is a Python package for multiplex community modeling with customizable interlayer ties.

## Why this package

Standard multislice approaches (Mucha et al. 2010) connect all layers to all layers, meaning community structure at distant time periods influences assignments everywhere. When applied to temporal data, this creates a pooling problem: the community configuration at 2010 affects the structure detected at 1950. `dynamic_multiplex` provides explicit control over *which layers influence which layers* via a `layer_links` argument (`from`, `to`, `weight`), defaulting to adjacent-only temporal coupling.

## Functions

- `fit_multilayer_jaccard()`
  - Fits Louvain or Leiden communities on each layer.
  - Builds interlayer ties between communities using Jaccard similarity across selected layer pairs.
- `fit_multilayer_overlap()`
  - Fits Louvain or Leiden communities on each layer.
  - Builds interlayer ties between communities using overlap coefficient across selected layer pairs.
- `fit_multilayer_weighted_jaccard()`
  - Fits Louvain or Leiden communities on each layer.
  - Builds interlayer ties using node-strength weighted Jaccard similarity across selected layer pairs.
- `fit_multilayer_weighted_overlap()`
  - Fits Louvain or Leiden communities on each layer.
  - Builds interlayer ties using node-strength weighted overlap coefficient across selected layer pairs.
- `fit_multilayer_identity_ties()`
  - Fits Louvain or Leiden communities on each layer.
  - Builds interlayer ties only for the same node across selected adjacent layers.
- `simulate_and_fit_multilayer()`
  - Simulates multiplex layers from a planted partition process and runs one of the three fitting strategies.

## Installation (development)

```bash
pip install -e ./python_code
```

Optional algorithms:

```bash
pip install -e ./python_code[louvain]
pip install -e ./python_code[leiden]
```

## Quick example

```python
from dynamic_multiplex import simulate_and_fit_multilayer, fit_multilayer_overlap

sim = simulate_and_fit_multilayer(
    directed=True,
    n_nodes=50,
    n_layers=4,
    n_communities=3,
    fit_type="jaccard",
    algorithm="louvain",
    seed=123,
)

print(sim["fit"]["interlayer_ties"].head())

custom_links = [
    {"from": 1, "to": 2, "weight": 1.0},
    {"from": 2, "to": 4, "weight": 0.6},
]

fit_overlap = fit_multilayer_overlap(
    sim["layers"],
    algorithm="leiden",
    layer_links=custom_links,
    min_similarity=0.1,
    add_self_loops=True,
    self_loop_multiplier=1.0,
)
```

## Testing

```bash
pip install -e ./python_code[dev,louvain]
pytest
```
