Graphify-Labs/graphify · error · RuntimeError

error: --multigraph requires NetworkX keyed MultiDiGraph nod

Error message

error: --multigraph requires NetworkX keyed MultiDiGraph node-link round-trip support. Detected Python {python_version}, NetworkX {networkx_version}. Failed capability check(s): {failed}. Default simple graph mode remains available.

What it means

RuntimeError raised by require_multigraph_capabilities() when probe_multigraph_capabilities() reports that the running Python/NetworkX combination cannot round-trip keyed MultiDiGraph node-link data (the --multigraph feature). The composed message embeds Python version, NetworkX version, and the specific failed capability checks, then notes that simple-graph mode remains available.

Source

Thrown at graphify/multigraph_compat.py:211

        ),
        _check(
            "to_undirected_preserves_multigraph_type",
            _probe_to_undirected_preserves_multigraph_type,
        ),
    )
    return MultigraphCapabilityResult(
        python_version=(
            f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
        ),
        networkx_version=nx.__version__,
        checks=checks,
    )


def require_multigraph_capabilities() -> MultigraphCapabilityResult:
    result = probe_multigraph_capabilities()
    if not result.ok:
        raise RuntimeError(result.error_message())
    return result

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. Upgrade NetworkX to the documented minimum: `pip install -U networkx`.
  2. Read the failed checks in the message - if the probe names a specific serialization gap, match the version graphify was tested against (see its requirements).
  3. If you cannot upgrade, drop --multigraph and run in default simple-graph mode, which the message confirms stays available.

Example fix

# before
$ graphify build --multigraph   # RuntimeError: requires NetworkX keyed MultiDiGraph...

# after
$ pip install -U networkx
$ graphify build --multigraph
# or, if the pin cannot move:
$ graphify build   # simple graph mode
Defensive patterns

Strategy: validation

Validate before calling

from graphify.multigraph_compat import probe_multigraph_capabilities
result = probe_multigraph_capabilities()
if not result.ok:
    print(f"--multigraph unavailable: {result.error_message()}")
    print("Falling back to simple graph mode.")
    use_multigraph = False
else:
    use_multigraph = True

Try / catch

try:
    result = require_multigraph_capabilities()
except RuntimeError as exc:
    raise SystemExit(f"{exc}\nRun without --multigraph, or upgrade networkx.") from exc

Prevention

When it happens

Trigger: Running graphify with --multigraph when the environment probe fails (multigraph_compat.py:207-211): the installed NetworkX predates (or deviates from) the keyed-multigraph node-link format support, or the Python version interacts badly with it. The exact failing checks are listed in the message.

Common situations: NetworkX pinned below ~3.x where node-link data lacked keyed multigraph edge support; downstream apps freezing old networkx versions; upgrading Python (e.g. to a brand-new minor) while a vendored old networkx stays; mixing conda-forge and pip networkx installs.

Related errors


AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14). Data as JSON: /api/errors/c4582368d55e2c8a. Report an issue: GitHub.