org.jgrapht.generate
Class RandomGraphGenerator<V,E>

java.lang.Object
  extended by org.jgrapht.generate.RandomGraphGenerator<V,E>
All Implemented Interfaces:
GraphGenerator<V,E,V>

public class RandomGraphGenerator<V,E>
extends java.lang.Object
implements GraphGenerator<V,E,V>

This Generator creates a random-topology graph of a specified number of vertexes and edges. An instance of this generator will always return the same graph-topology in calls to generateGraph(). The vertexes can be different (depends on the VertexFactory implementation)

However, two instances which use the same constructor parameters will produce two different random graphs (note: as with any random generator, there is always a small possibility that two instances will create the same results).

Since:
Aug 6, 2005
Author:
Assaf Lehr

Nested Class Summary
 class RandomGraphGenerator.DefaultEdgeTopologyFactory<VV,EE>
          Default implementation of the EdgeTopologyFactory interface.
static interface RandomGraphGenerator.EdgeTopologyFactory<VV,EE>
          This class is used to generate the edge topology for a graph.
 
Field Summary
protected  int numOfEdges
           
protected  int numOfVertexes
           
protected  java.util.Random randomizer
           
 
Constructor Summary
RandomGraphGenerator(int aNumOfVertexes, int aNumOfEdges)
           
 
Method Summary
 void generateGraph(Graph<V,E> target, VertexFactory<V> vertexFactory, java.util.Map<java.lang.String,V> resultMap)
          (non-Javadoc)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numOfVertexes

protected int numOfVertexes

numOfEdges

protected int numOfEdges

randomizer

protected java.util.Random randomizer
Constructor Detail

RandomGraphGenerator

public RandomGraphGenerator(int aNumOfVertexes,
                            int aNumOfEdges)
Method Detail

generateGraph

public void generateGraph(Graph<V,E> target,
                          VertexFactory<V> vertexFactory,
                          java.util.Map<java.lang.String,V> resultMap)
(non-Javadoc)

Specified by:
generateGraph in interface GraphGenerator<V,E,V>
Parameters:
target - receives the generated edges and vertices; if this is non-empty on entry, the result will be a disconnected graph since generated elements will not be connected to existing elements
vertexFactory - called to produce new vertices
resultMap - if non-null, receives implementation-specific mappings from String roles to graph elements (or collections of graph elements)
Throws:
java.lang.IllegalArgumentException - if the aNumOfEdges passed in the constructor, cannot be created on a graph of the concrete type with aNumOfVertexes. org.jgrapht.generate.RandomGraphGenerator.DefaultEdgeTopologyFactory#isNumberOfEdgesValid(org.jgrapht.Graph, int)
See Also:
GraphGenerator.generateGraph(Graph, VertexFactory, Map)