concepts.benchmark.algorithm_env.graph.random_generate_graph#
- random_generate_graph(n, p, directed=False, np_random=None)[source]#
Randomly generate a graph by sampling the existence of each edge. Each edge between nodes has the probability p (directed) or p^2 (undirected) to not exist.
This paradigm is also called the Erdős–Rényi model.
- Parameters:
n (int) – the number of nodes in the graph.
p (float) – the probability that a edge doesn’t exist in directed graph.
directed (bool) – directed or Undirected graph. Default: False (undirected).
np_random (RandomState | None) – the random state.
- Returns:
generated graph.
- Return type:
graph