xgi.generators.simplicial_complexes
Generators for some simplicial complexes.
All the functions in this module return a SimplicialComplex class.
Functions
- xgi.generators.simplicial_complexes.flag_complex(G, max_order=2, ps=None, seed=None)[source]
Generate a flag (or clique) complex from a NetworkX graph by filling all cliques up to dimension max_order.
- Parameters:
G (Networkx Graph) –
max_order (int) – maximal dimension of simplices to add to the output simplicial complex
ps (list of float) – List of probabilities (between 0 and 1) to create a hyperedge from a clique, at each order d. For example, ps[0] is the probability of promoting any 3-node clique (triangle) to a 3-hyperedge.
seed (int or None (default)) – The seed for the random number generator
- Returns:
S
- Return type:
Notes
Computing all cliques quickly becomes heavy for large networks. flag_complex_d2 is faster to compute up to order 2.
See also
- xgi.generators.simplicial_complexes.flag_complex_d2(G, p2=None, seed=None)[source]
Generate a flag (or clique) complex from a NetworkX graph by filling all cliques up to dimension 2.
- Parameters:
G (networkx Graph) – Graph to consider
p2 (float) – Probability (between 0 and 1) of filling empty triangles in graph G
seed (int or None (default)) – The seed for the random number generator
- Returns:
S
- Return type:
xgi.SimplicialComplex
Notes
Computing all cliques quickly becomes heavy for large networks. This is faster than flag_complex to compute up to order 2.
See also
- xgi.generators.simplicial_complexes.random_flag_complex(N, p, max_order=2, seed=None)[source]
Generate a flag (or clique) complex from a \(G_{N,p}\) Erdős-Rényi random graph.
This proceeds by filling all cliques up to dimension max_order.
- Parameters:
N (int) – Number of nodes
p (float) – Probability (between 0 and 1) to create an edge between any 2 nodes
max_order (int) – maximal dimension of simplices to add to the output simplicial complex
seed (int or None (default)) – The seed for the random number generator
- Return type:
Notes
Computing all cliques quickly becomes heavy for large networks.
- xgi.generators.simplicial_complexes.random_flag_complex_d2(N, p, seed=None)[source]
Generate a maximal simplicial complex (up to order 2) from a \(G_{N,p}\) Erdős-Rényi random graph.
This proceeds by filling all empty triangles in the graph with 2-simplices.
- Parameters:
N (int) – Number of nodes
p (float) – Probabilities (between 0 and 1) to create an edge between any 2 nodes
seed (int or None (default)) – The seed for the random number generator
- Return type:
Notes
Computing all cliques quickly becomes heavy for large networks.
- xgi.generators.simplicial_complexes.random_simplicial_complex(N, ps, seed=None)[source]
Generates a random hypergraph
Generate N nodes, and connect any d+1 nodes by a simplex with probability ps[d-1]. For each simplex, add all its subfaces if they do not already exist.
- Parameters:
N (int) – Number of nodes
ps (list of float) – List of probabilities (between 0 and 1) to create a hyperedge at each order d between any d+1 nodes. For example, ps[0] is the wiring probability of any edge (2 nodes), ps[1] of any triangles (3 nodes).
seed (int or None (default)) – The seed for the random number generator
- Returns:
The generated simplicial complex
- Return type:
Simplicialcomplex object
References
Described as ‘random simplicial complex’ in “Simplicial Models of Social Contagion”, Nature Communications 10(1), 2485, by I. Iacopini, G. Petri, A. Barrat & V. Latora (2019). https://doi.org/10.1038/s41467-019-10431-6
Example
>>> import xgi >>> H = xgi.random_simplicial_complex(20, [0.1, 0.01])