babylon.engine.graph_wrappers
Typed graph wrappers for Spec 040 Discipline 5.
Enforces separation between dyadic edges (NetworkX DiGraph) and hyperedges (XGI Hypergraph). Systems access graph topology through these typed wrappers, not raw data structures.
DyadicGraph: Wraps nx.DiGraph for pairwise (source → target) edges. CommunityHypergraph: Wraps xgi.Hypergraph for n-ary community membership.
Classes
|
Typed wrapper for XGI Hypergraph (n-ary community membership). |
|
Typed wrapper for NetworkX DiGraph (pairwise edges). |
- class babylon.engine.graph_wrappers.DyadicGraph(graph)[source]
Bases:
objectTyped wrapper for NetworkX DiGraph (pairwise edges).
Provides typed edge operations that enforce EdgeType on all edge queries and mutations.
- Parameters:
graph (nx.DiGraph[str])
- raw
The underlying NetworkX DiGraph.
- __init__(graph)[source]
Wrap a NetworkX DiGraph.
- Parameters:
graph – The raw NetworkX directed graph.
- class babylon.engine.graph_wrappers.CommunityHypergraph(hypergraph=None)[source]
Bases:
objectTyped wrapper for XGI Hypergraph (n-ary community membership).
Provides typed community operations for adding communities, querying membership, and computing overlap.
- Parameters:
hypergraph (xgi.Hypergraph | None)
- __init__(hypergraph=None)[source]
Initialize with an optional existing hypergraph.
- Parameters:
hypergraph (
Hypergraph|None) – Existing XGI Hypergraph, or None for empty.- Return type:
None
- property raw: Hypergraph
Access the underlying raw hypergraph.
Find communities shared by two agents.