xgi.generators.randomizing#
Functions to randomize hypergaphs
All the functions in this module return a Hypergraph class (i.e. a simple, undirected hypergraph).
Functions
- shuffle_hyperedges(S, order, p, seed=None)[source]#
Shuffle existing hyperdeges of order order with probablity p.
- Parameters:
S (xgi.Hypergraph) – Hypergraph
order (int) – Order of hyperedges to shuffle
p (float) – Probability of shuffling each hyperedge
seed (integer or None (default)) – Seed for the random number generator.
- Returns:
H – Hypergraph with edges of order d shuffled
- Return type:
xgi.Hypergraph
Note
By shuffling hyperedges in a simplicial complex, it will in general lose its “simpliciality” and become a hypergraph.
References
Zhang, Y.*, Lucas, M.* and Battiston, F., 2023. “Higher-order interactions shape collective dynamics differently in hypergraphs and simplicial complexes.” Nature Communications, 14(1), p.1605. https://doi.org/10.1038/s41467-023-37190-9
Example
>>> S = xgi.random_simplicial_complex(50, [0.1, 0.01, 0.001], seed=1) >>> H = xgi.shuffle_hyperedges(S, order=2, p=0.5)
- node_swap(H, nid1, nid2, id_temp=-1, order=None)[source]#
Swap nodes nid1 and node nid2 in all edges of order order.
- Parameters:
H (Hypergraph) – Hypergraph to consider
nid1 (node ID) – ID of first node to swap
nid2 (node ID) – ID of second node to swap
id_temp (node ID) – Temporary ID given to nodes when swapping
order ({int, None}, default: None) – If None, consider all orders. If an integer, consider edges of that order.
- Returns:
HH (Hypergraph)
Reference
———
Zhang, Y., Lucas, M.* and Battiston, F., 2023.*
”Higher-order interactions shape collective dynamics differently
in hypergraphs and simplicial complexes.”
Nature Communications, 14(1), p.1605.
https (//doi.org/10.1038/s41467-023-37190-9)