Skip to main content

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)

pip install -e ./python_code

Optional algorithms:

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

Quick example

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

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dynamic_multiplex-1.1.0.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynamic_multiplex-1.1.0-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file dynamic_multiplex-1.1.0.tar.gz.

File metadata

  • Download URL: dynamic_multiplex-1.1.0.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for dynamic_multiplex-1.1.0.tar.gz
Algorithm Hash digest
SHA256 1925da8ec56f057e7145dc6b82e059a888d9c37552b7a96a26aa016a37a8dda9
MD5 f80e872dc0424a04f694c86dc355bbe9
BLAKE2b-256 9ed5779b279eedc3eec04316b1ddeb5c7b961e0f925a11991bb0b5dfadd50fd3

See more details on using hashes here.

File details

Details for the file dynamic_multiplex-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dynamic_multiplex-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2109342f3b25df00e2f142ad7b4ea0a47842d7f5623920858e2cf9bce38fb9ba
MD5 630d5dac540ea734b762a0081a0de637
BLAKE2b-256 f1e7ada710658d4ed0d16c12f4adfc96ac841ea6130fa53b4f92d4d923458286

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page