xgi.encapsulation_dag

Functions

xgi.encapsulation_dag.empirical_subsets_filter(H, dag)

Filters encapsulation DAG of H in place to only include edges between hyperedges of size k and the maximum existing k’.

Parameters:
  • H (Hypergraph) – The hypergraph of interest

  • dag (nx.DiGraph) – The encapsulation dag of H constructed with to_encapsulation_dag(H, subset_types=”all”)

Returns:

dag – The filtered line graph (also modified in place)

Return type:

networkx.DiGraph

References

“Encapsulation Structure and Dynamics in Hypergraphs”, by Timothy LaRock & Renaud Lambiotte. https://arxiv.org/abs/2307.04613

xgi.encapsulation_dag.to_encapsulation_dag(H, subset_types='all')

The encapsulation DAG (Directed Acyclic Graph) of the hypergraph H.

An encapsulation DAG is a directed line graph where the nodes are hyperedges in H and a directed edge exists from a larger hyperedge to a smaller hyperedge if the smaller is a subset of the larger.

Parameters:
  • H (Hypergraph) – The hypergraph of interest

  • subset_types (str, optional) –

    Type of relations to include. Options are:

    ”all” : all subset relationships “immediate” : only subset relationships between hyperedges of

    adjacent sizes (i.e., edges from k to k-1)

    ”empirical”A relaxation of the “immediate” option where only

    subset relationships between hyperedges of size k and subsets of maximum size k’<k existing in the hypergraph are included. For example, a hyperedge of size 5 may have no immediate encapsulation relationships with hyperedges of size 4, but may encapsulate hyperedegs of size 3, which will be included if using this setting (whereas relationships with subsets of size 2 would not be included).

Returns:

LG – The line graph associated to the Hypergraph

Return type:

networkx.DiGraph

Examples

>>> import xgi
>>> from xgi.convert import to_encapsulation_dag, empirical_subsets_filter
>>> H = xgi.Hypergraph([["a","b","c"], ["b","c","f"], ["a","b"], ["c", "e"], ["a"], ["f"]])
>>> dag = to_encapsulation_dag(H)
>>> dag.edges()
OutEdgeView([(0, 2), (0, 4), (2, 4), (1, 5)])
>>> dag = to_encapsulation_dag(H, subset_types="immediate")
>>> dag.edges()
OutEdgeView([(0, 2), (2, 4)])
>>> dag = to_encapsulation_dag(H, subset_types="empirical")
>>> dag.edges()
OutEdgeView([(0, 2), (2, 4), (1, 5)])

References

“Encapsulation Structure and Dynamics in Hypergraphs”, by Timothy LaRock & Renaud Lambiotte. https://arxiv.org/abs/2307.04613