Class ErdosRenyiGraph

All Implemented Interfaces:
FlyweightPrototype<ImmutableGraph>

public class ErdosRenyiGraph
extends ImmutableSequentialGraph
An Erdős–Rényi random graph: the number of nodes is fixed, and there is a fixed probability that an arc is put between any two nodes (independently for every pair).

Note that an instance of this class is not random-access: you can, however, make a mutable copy of the returned graph and then take its immutable view.

Warning: From version 3.5.2, this classes uses BinomialDistribution instead of the previous COLT-based Binomial class. As a side-effect, the graphs generated with the same parameters will be different.

  • Constructor Details

    • ErdosRenyiGraph

      public ErdosRenyiGraph​(int n, double p, long seed, boolean loops)
      Creates an Erdős–Rényi graph with given parameters and random seed.
      Parameters:
      n - the number of nodes.
      p - the probability of generating an arc.
      seed - a seed for pseudorandom number generation.
      loops - whether loops are allowed or not.
    • ErdosRenyiGraph

      public ErdosRenyiGraph​(int n, double p, boolean loops)
      Creates an Erdős–Rényi graph with given parameters.
      Parameters:
      n - the number of nodes.
      p - the probability of generating an arc.
      loops - whether loops are allowed or not.
    • ErdosRenyiGraph

      public ErdosRenyiGraph​(int n, double p)
      Creates an Erdős–Rényi graph with given parameters and no loops.
      Parameters:
      n - the number of nodes.
      p - the probability of generating an arc.
    • ErdosRenyiGraph

      public ErdosRenyiGraph​(String n, String p, String seed, String loops)
      Creates an Erdős–Rényi graph with given parameters and random seed.

      This constructor can be used with an ObjectParser.

      Parameters:
      n - the number of nodes.
      p - the probability of generating an arc.
      seed - a seed for pseudorandom number generation.
      loops - whether loops are allowed or not.
    • ErdosRenyiGraph

      public ErdosRenyiGraph​(String n, String p)
      Creates an Erdős–Rényi graph with given parameters and no loops.

      This constructor can be used with an ObjectParser.

      Parameters:
      n - the number of nodes.
      p - the probability of generating an arc.
    • ErdosRenyiGraph

      public ErdosRenyiGraph​(String n, String p, String loops)
      Creates an Erdős–Rényi graph with given parameters.

      This constructor can be used with an ObjectParser.

      Parameters:
      n - the number of nodes.
      p - the probability of generating an arc.
      loops - whether loops are allowed or not.
    • ErdosRenyiGraph

      public ErdosRenyiGraph​(int n, long m, long seed, boolean loops)
      Creates an Erdős–Rényi graph with given parameters and random seed.
      Parameters:
      n - the number of nodes.
      m - the expected number of arcs.
      seed - a seed for pseudorandom number generation.
      loops - whether loops are allowed or not.
    • ErdosRenyiGraph

      public ErdosRenyiGraph​(int n, long m, boolean loops)
      Creates an Erdős–Rényi graph with given parameters and random seed.
      Parameters:
      n - the number of nodes.
      m - the expected number of arcs.
      loops - whether loops are allowed or not.
  • Method Details