concepts.benchmark.algorithm_env.graph.random_generate_graph#

random_generate_graph(n, p, directed=False)[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 – The number of nodes in the graph.

  • p – the probability that a edge doesn’t exist in directed graph.

  • directed – Directed or Undirected graph. Default: False (undirected).

Returns:

Generated graph.

Return type:

graph