Class ErdosRenyiGenerator<V,E>

java.lang.Object
edu.uci.ics.jung.algorithms.generators.random.ErdosRenyiGenerator<V,E>
All Implemented Interfaces:
com.google.common.base.Supplier<Graph<V,E>>, GraphGenerator<V,E>, Supplier<Graph<V,E>>

public class ErdosRenyiGenerator<V,E> extends Object implements GraphGenerator<V,E>
Generates a random graph using the Erdos-Renyi binomial model (each pair of vertices is connected with probability p).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) com.google.common.base.Supplier<E>
     
    (package private) com.google.common.base.Supplier<UndirectedGraph<V,E>>
     
    private double
     
    private int
     
    private Random
     
    (package private) com.google.common.base.Supplier<V>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ErdosRenyiGenerator(com.google.common.base.Supplier<UndirectedGraph<V,E>> graphFactory, com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory, int numVertices, double p)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    get()
    Returns a graph in which each pair of vertices is connected by an undirected edge with the probability specified by the constructor.
    void
    setSeed(long seed)
    Sets the seed of the internal random number generator to seed.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.google.common.base.Supplier

    equals
  • Field Details

    • mNumVertices

      private int mNumVertices
    • mEdgeConnectionProbability

      private double mEdgeConnectionProbability
    • mRandom

      private Random mRandom
    • graphFactory

      com.google.common.base.Supplier<UndirectedGraph<V,E>> graphFactory
    • vertexFactory

      com.google.common.base.Supplier<V> vertexFactory
    • edgeFactory

      com.google.common.base.Supplier<E> edgeFactory
  • Constructor Details

    • ErdosRenyiGenerator

      public ErdosRenyiGenerator(com.google.common.base.Supplier<UndirectedGraph<V,E>> graphFactory, com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory, int numVertices, double p)
      Parameters:
      graphFactory - factory for graphs of the appropriate type
      vertexFactory - factory for vertices of the appropriate type
      edgeFactory - factory for edges of the appropriate type
      numVertices - number of vertices graph should have
      p - Connection's probability between 2 vertices
  • Method Details

    • get

      public Graph<V,E> get()
      Returns a graph in which each pair of vertices is connected by an undirected edge with the probability specified by the constructor.
      Specified by:
      get in interface com.google.common.base.Supplier<V>
      Specified by:
      get in interface Supplier<V>
    • setSeed

      public void setSeed(long seed)
      Sets the seed of the internal random number generator to seed. Enables consistent behavior.
      Parameters:
      seed - the seed to use for the internal random number generator