igraph adapter
Convert between an AnnNet object and an igraph
graph. igraph holds nodes, binary edges and their attributes. to_igraph also
gives back a manifest with what igraph cannot hold, such as hyperedges, slices
and layers. Give the manifest to from_igraph to rebuild the full graph. To
run an igraph algorithm without converting yourself, use
anet.ig.
annnet.adapters.igraph_adapter.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.
annnet.adapters.igraph_adapter.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(anet)) 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