Skip to content

igraph Adapter

igraph conversion helpers from annnet.adapters.igraph_adapter.

annnet.adapters.igraph_adapter

AnnNet-igraph adapter for AnnNet.

Provides: to_igraph(G) -> igraph.Graph from_igraph(igG) -> AnnNet

igraph natively represents: - nodes - binary edges - graph, node, and edge attributes

AnnNet-specific structures such as hyperedges, slices, multilayer metadata, per-edge directedness, and richer attribute tables are preserved through manifest-style graph attributes where possible.

Classes

Functions

to_igraph
to_igraph(
    graph,
    directed=True,
    hyperedge_mode="skip",
    hyperedges=None,
    coefficients="error",
    slice=None,
    slices=None,
    public_only=False,
    reify_prefix="he::",
)

Export AnnNet → (igraph graph, manifest).

from_igraph takes the manifest as its second argument, so from_igraph(*to_igraph(G)) is the round trip.

hyperedges : str, optional The same choice as hyperedge_mode, under the name every exporter shares, and accepting "star" and "clique" as aliases for "reify" and "expand". Takes precedence when both are given. coefficients : {"error", "drop"}, default "error" What to do when the projection would drop per-member coefficients. Only "expand" loses them, and losing them silently is what this refuses. hyperedge_mode: {"skip","expand","reify"} - "skip": drop HE edges from igG (manifest keeps them) - "expand": cartesian product (directed) / clique (undirected) - "reify": add a node per HE and membership edges V↔HE carrying roles/coeffs

from_igraph
from_igraph(
    igG,
    manifest,
    *,
    hyperedge="none",
    he_node_flag="is_hyperedge",
    he_id_attr="eid",
    reify_prefix="he::"
)

Reconstruct a AnnNet from igraph.AnnNet + manifest.

hyperedge: "none" (default) | "reified" When "reified", also detect hyperedge nodes in igG and rebuild true hyperedges that are NOT present in the manifest.