Skip to main content

disentangled-net

A Python library designed for disentangled structure inferences on networks (communities and embeddings). It provides advanced topological tools to purge networks of spatial (given nodes position) or custom null model effects, allowing the extraction of unbiased communities and node embeddings.

Citation Note: If you use this code or repository for your research paper, please cite: [Insert Citation Here Upon Publication].

Installation

To install the official release via PyPI:

pip install disentangled-net

To install in development mode from the cloned repository root:

pip install -e .

Repository Structure & Core Modules

The library is modularly designed around five key components inside the src/ directory:

  • disentangled_louvain_communities.py: Exposes the public API for community detection. It includes two callable functions: infer_spatial_disentangled_louvain_communities to extract communities using node coordinates, and infer_custom_disentangled_louvain_communities to infer communities using a user-provided probability matrix of size $N \times N$ representing a custom Null Model.

  • disentangled_embeddings.py: Implements a custom PyTorch-based signed network embedding algorithm. It optimizes a continuous node representation space based on network residual intensities, leveraging either spatial positions or a custom $N \times N$ external Null Model matrix. Available functions : infer_spatial_disentangled_embeddings and infer_custom_disentangled_embeddings.

  • SpatialNullModelInference.py: Handles the maximum likelihood estimation (MLE) of the Degree-Corrected Spatial Null Model. It infers coordinate-based $\alpha$ and $\beta$ parameters to generate the background spatial probability matrix.

  • MetaLouvain.py: Contains the core modularity optimization algorithms tailored for the inference of Null-Model disentangled network partitions.

  • utils.py: Provides mathematical and structural validation utilities, such as checking partition robustness across different resolution scales.

Quick Start

import networkx as nx
import numpy as np
from disentangled_net import infer_spatial_disentangled_louvain_communities, infer_spatial_disentangled_embeddings

# 1. Load a NetworkX Graph with a spatial position attribute
G = nx.erdos_renyi_graph(n=50, p=0.1)

# Example : a random 2D position in [0;1] is assigned to every node
for node in G.nodes:
    G.nodes[node]['GT_pos'] = np.random.rand(2)

# 2. Extract spatially disentangled communities (modifies G in place)
G = infer_spatial_disentangled_louvain_communities(
    G=G, 
    pos_attr="GT_pos", 
    attr_name="spatially_disentangled_louvain_id"
)

# 3. Generate spatially disentangled continuous embeddings (modifies G in place)
G = infer_spatial_disentangled_embeddings(
    G=G, 
    pos_attr="GT_pos", 
    attr_name= "spatially_disentangled_embedding",
    embedding_dim=64
)

# Nodes now contain both disentangled attributes
print(G.nodes[0])

If you want to infer disentangled communities and embeddings from something else than node positions, you can do so by using your own NullModel matrix, of size N_nodes * N_nodes :

import networkx as nx
import numpy as np
from disentangled_net import infer_custom_disentangled_louvain_communities, infer_custom_disentangled_embeddings

G = nx.erdos_renyi_graph(n=50, p=0.1)
nodes_list = list(G.nodes())

# Example: a dummy 50x50 probability matrix
customNullModel = np.full((50, 50), 0.05)

# 2. Extract custom disentangled communities (modifies G in place)
G = infer_custom_disentangled_louvain_communities(
    G=G, 
    null_model_matrix=customNullModel, 
    ordered_nodes=nodes_list,
    attr_name="custom_disentangled_louvain_id"
)

# 3. Generate custom disentangled continuous embeddings (modifies G in place)
G = infer_custom_disentangled_embeddings(
    G=G, 
    null_model_matrix=customNullModel, 
    ordered_nodes=nodes_list,
    attr_name="custom_disentangled_embedding",
    embedding_dim=64
)

# Nodes now contain both custom disentangled attributes
print(G.nodes[0])

Authors

DUPUY Guilhem - guilhempds@gmail.com CAZABET Rémy - remy.cazabet@gmail.com

Metadata

Release files for disentangled-net 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for disentangled-net 0.1.0
File Size Uploaded Provenance Actions
disentangled_net-0.1.0.tar.gz 12.6 kB Without provenance Details for disentangled_net-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for disentangled-net 0.1.0
File Interpreter ABI Platform Actions
disentangled_net-0.1.0-py3-none-any.whl Python 3 none any Details for disentangled_net-0.1.0-py3-none-any.whl

Total release size: 28.2 kB

Release files / disentangled_net-0.1.0.tar.gz

Download URL disentangled_net-0.1.0.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9affa57a05fcb47f5cbb94c923ec778bbb39af2ca28e19d8d2b17a35c0b67d81
BLAKE2b-256 checksum
How to use checksums
a07f8ae17c93576bfadd8153348f4fd7c9774d7cb894228c353ccbc2aed8742e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.17.1 {"ci":null,"cpu":"x86_64","distro":{"name":"macOS","version":"15.7.7"},"implementation":{"name":"CPython","version":"3.10.15"},"installer":{"name":"hatch","version":"1.17.1"},"openssl_version":"OpenSSL 3.6.1 27 Jan 2026","python":"3.10.15","system":{"name":"Darwin","release":"24.6.0"}} HTTPX2/2.7.0

Release files / disentangled_net-0.1.0-py3-none-any.whl

Download URL disentangled_net-0.1.0-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8983c4205952b8186282c335fae94d5e1c4eab91b84094f6cd48dcc2385d5004
BLAKE2b-256 checksum
How to use checksums
bd5460b7893ac1adfe0a7bd30c61cad626239fd98a1b956d5831bd3efd71d2fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.17.1 {"ci":null,"cpu":"x86_64","distro":{"name":"macOS","version":"15.7.7"},"implementation":{"name":"CPython","version":"3.10.15"},"installer":{"name":"hatch","version":"1.17.1"},"openssl_version":"OpenSSL 3.6.1 27 Jan 2026","python":"3.10.15","system":{"name":"Darwin","release":"24.6.0"}} HTTPX2/2.7.0

Security for disentangled-net 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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