Skip to content

Commit

Permalink
feat: added seed to shuffle-hypedges (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximelucas authored Jan 14, 2025
1 parent ddc5cbb commit b4f9f38
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xgi/generators/randomizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]


def shuffle_hyperedges(S, order, p):
def shuffle_hyperedges(S, order, p, seed=None):
"""Shuffle existing hyperdeges of order `order` with probablity `p`.
Parameters
Expand All @@ -26,6 +26,8 @@ def shuffle_hyperedges(S, order, p):
Order of hyperedges to shuffle
p : float
Probability of shuffling each hyperedge
seed : integer or None (default)
Seed for the random number generator.
Returns
-------
Expand All @@ -52,6 +54,9 @@ def shuffle_hyperedges(S, order, p):
"""

if seed is not None:
random.seed(seed)

if (order + 1) not in xgi.unique_edge_sizes(S):
raise ValueError(f"There is no hyperedge of order {order} is this hypergraph.")
if (p < 0) or (p > 1):
Expand Down

0 comments on commit b4f9f38

Please sign in to comment.