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.0.0.tar.gz (17.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.0.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dynamic_multiplex-1.0.0.tar.gz
  • Upload date:
  • Size: 17.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.0.0.tar.gz
Algorithm Hash digest
SHA256 fadfce9db6b25009a6f6d3b02c69a4294bf6129e5a9190c0477d03c3f41ed69a
MD5 f6accff10526c49b82a5fcc84ee47e27
BLAKE2b-256 3db6ec1917bbdc1ba38b31a6941d255ac66a3265a180401e691b3c3277776478

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dynamic_multiplex-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d3551807f6b0dc869df9e65db1c79391a8b3bb71aa50a2d71fa0884852d115b4
MD5 e1a8f8fac1474460fef25fa243928757
BLAKE2b-256 6482c720447b7a3d49e0e789a53fb004c86df278373962717eb656e8f26f98fe

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.0

2 files

This release

1.0.0 This release

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