Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix multiplex example#1265

Merged
SkBlaz merged 1 commit intomasterSkBlaz/py3plex:masterfrom
fix-exampleSkBlaz/py3plex:fix-exampleCopy head branch name to clipboard
Mar 12, 2026
Merged

Fix multiplex example#1265
SkBlaz merged 1 commit intomasterSkBlaz/py3plex:masterfrom
fix-exampleSkBlaz/py3plex:fix-exampleCopy head branch name to clipboard

Conversation

@SkBlaz
Copy link
Copy Markdown
Owner

@SkBlaz SkBlaz commented Mar 9, 2026

Summary

Fixes the supra-adjacency docs mismatch reported in #1262 and addresses the underlying multiplex generator behavior that made the documented expectation unreliable.

This PR does two things:

  1. Fixes the documentation to use the correct generator for a classic multiplex supra-adjacency example.
  2. Fixes random_multiplex_ER() so it always materializes all node replicas across all layers, including isolated ones.

Problem

The docs example in Section 3.8 expected:

  • 100 nodes
  • 3 layers
  • supra-adjacency shape (300, 300)

but used random_multilayer_ER(...), which generates a general multilayer network where each base node is assigned to a single layer. In that case, the supra-adjacency size reflects
the number of node-layer pairs that actually exist, which is typically n, not n * l.

Separately, random_multiplex_ER(...) did not explicitly add isolated replicas, so even in multiplex mode the supra-adjacency shape was not guaranteed to be exactly n * l when some
nodes had no incident edges in a layer.

Root cause

  • Docs issue: the example used random_multilayer_ER(...) where random_multiplex_ER(...) was intended.
  • Implementation issue: random_multiplex_ER(...) only added nodes implicitly through edges, so isolated node-layer replicas could be missing.

Changes

Code

  • Update random_multiplex_ER() to add all (node, layer) replicas before adding edges.
  • Make multiplex supra-matrix encoding robust for empty graphs.
  • Use stable base-node ordering during multiplex encoding so layer blocks align consistently.

Docs

  • Update the supra-adjacency example in the book to use random_multiplex_ER(...).
  • Clarify the semantic difference between:
    • random_multilayer_ER(...) → general multilayer, present replicas only
    • random_multiplex_ER(...) → strict multiplex, all n * l replicas

Tests

  • Add regression coverage for:
    • random_multilayer_ER(...) producing a supra shape based on present replicas
    • random_multiplex_ER(...) preserving all replicas even when p=0

Expected behavior after this PR

  • random_multilayer_ER(100, 3, p) produces a supra-adjacency matrix sized by the actual node-layer pairs present.
  • random_multiplex_ER(100, 3, p) produces a supra-adjacency matrix of shape (300, 300).

Validation

Direct sanity checks confirm:

  • random_multilayer_ER(12, 3, 0.4) → (12, 12)
  • random_multiplex_ER(8, 4, 0.0) → (32, 32)
  • random_multiplex_ER(100, 3, 0.05) → (300, 300)

Closes

Closes #1262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.