Class ErdosRenyiGenerator

Inheritance Relationships

Base Type

Class Documentation

class ErdosRenyiGenerator : public NetworKit::StaticGraphGenerator

Creates G(n, p) graphs.

This class is a wrapper to ErdosRenyiEnumerator.

Public Functions

ErdosRenyiGenerator(count nNodes, double prob, bool directed = false, bool self_loops = false)

Creates random graphs in the G(n,p) model. The generation follows a parallelized version of Vladimir Batagelj and Ulrik Brandes: “Efficient generation of large random networks”, Phys Rev E 71, 036113 (2005) with a runtime of O((n+m) / P) (WHP), where n, m, and P are the numbers of nodes, edges and parallel threads respectively.

The generator can also be used to generate empty or complete graphs efficiently by setting (p = 0.0 or p = 1.0). Observe that this is implemented as a special case and requires p to be exactly zero or one.

Warning

For compatibility reasons, the generator does not produce self-loops by default.

Parameters:
  • nNodes – Number of nodes n in the graph.

  • prob – Probability of existence for each edge p.

  • directed – generates a directed graph

  • self_loops – Controls whether a directed graph may contain self_loops (undirected graphs never have them)

virtual Graph generate() override