xgi.generators.classic#
Generators for some classic hypergraphs.
All the functions in this module return a Hypergraph class (i.e. a simple, undirected hypergraph).
Functions
- empty_hypergraph(create_using=None, default=None)[source]#
Returns the empty hypergraph with zero nodes and edges.
- Parameters:
create_using (Hypergraph Instance, Constructor or None) – If None, use the default constructor. If a constructor, call it to create an empty hypergraph.
default (Hypergraph constructor (default None)) – The constructor to use if create_using is None. If None, then xgi.Hypergraph is used.
- Returns:
An empty hypergraph
- Return type:
Hypergraph object
See also
Examples
>>> import xgi >>> H = xgi.empty_hypergraph() >>> H.num_nodes, H.num_edges (0, 0)
- empty_simplicial_complex(create_using=None, default=None)[source]#
Returns the empty simplicial complex with zero nodes and simplices.
- Parameters:
create_using (SimplicialComplex Instance, Constructor or None) – If None, use the default constructor. If a constructor, call it to create an empty simplicial complex.
default (SimplicialComplex constructor (default None)) – The constructor to use if create_using is None. If None, then xgi.SimplicialComplex is used.
- Returns:
An empty simplicial complex.
- Return type:
See also
Examples
>>> import xgi >>> H = xgi.empty_simplicial_complex() >>> H.num_nodes, H.num_edges (0, 0)
- trivial_hypergraph(n=1, create_using=None, default=None)[source]#
Returns a hypergraph with n nodes and zero edges.
- Parameters:
n (int, optional) – Number of nodes (default is 1)
create_using (Hypergraph Instance, Constructor or None) – If None, use the default constructor. If a constructor, call it to create an empty hypergraph.
default (Hypergraph constructor (default None)) – The constructor to use if create_using is None. If None, then xgi.Hypergraph is used.
- Returns:
A trivial hypergraph with n nodes
- Return type:
Hypergraph object
See also
Examples
>>> import xgi >>> H = xgi.trivial_hypergraph() >>> H.num_nodes, H.num_edges (1, 0)
- complete_hypergraph(N, order=None, max_order=None, include_singletons=False)[source]#
Generate a complete hypergraph, i.e. one that contains all possible hyperdges at a given order or up to a max_order.
- Parameters:
N (int) – Number of nodes
order (int or None) – If not None (default), specifies the single order for which to generate hyperedges
max_order (int or None) – If not None (default), specifies the maximum order for which to generate hyperedges
include_singletons (bool) – Whether to include singleton edges (default: False). This argument is discarded if max_order is None.
- Returns:
A complete hypergraph with N nodes
- Return type:
Hypergraph object
Notes
Only one of order and max_order can be specified by and int (not None). Additionally, at least one of either must be specified.
The number of possible edges grows exponentially as \(2^N\) for large N and quickly becomes impractically long to compute, especially when using max_order. For example, N=100 and max_order=5 already yields \(10^8\) edges. Increasing N=1000 makes it \(10^{13}\). N=100 and with a larger max_order=6 yields \(10^9\) edges.
- complement(H)[source]#
Returns the complement of hypergraph H.
The complement Hc of a hypergraph H has the same nodes (same indexes) as H and contains every possible hyperedge linking these nodes, except those present in H. Also, the maximum hyperedge size in Hc is the same as in H. Hyperedges of size one are taken into account.
- Parameters:
H (xgi.Hypergraph) – Hypergraph to complement.
- Returns:
Hc – Complement of H.
- Return type:
xgi.Hypergraph