edu.uci.ics.jung.random.generators
Class Lattice1DGenerator

java.lang.Object
  extended by edu.uci.ics.jung.random.generators.Lattice1DGenerator
All Implemented Interfaces:
GraphGenerator
Direct Known Subclasses:
WattsBetaSmallWorldGenerator

public class Lattice1DGenerator
extends Object
implements GraphGenerator

Simple generator of an n x 1 lattice where each vertex is incident with each of its 2 neighbors (except possibly for the vertices on the edge depending upon whether the lattice is specified to be toroidal or not).

Author:
Scott White

Constructor Summary
Lattice1DGenerator(int numNodes, boolean isToroidal)
          Constructs an instance of the lattice generator
 
Method Summary
protected  int downIndex(int currentIndex, int numSteps)
          Determines the vertices with a smaller index that are in the neighborhood of currentIndex.
 ArchetypeGraph generateGraph()
          Instructs the algorithm to generate the graph
protected  int upIndex(int currentIndex, int numSteps)
          Determines the index of the neighbor ksteps above
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lattice1DGenerator

public Lattice1DGenerator(int numNodes,
                          boolean isToroidal)
Constructs an instance of the lattice generator

Parameters:
numNodes - # of nodes in the generated graph
isToroidal - whether the lattice wraps around or not
Method Detail

generateGraph

public ArchetypeGraph generateGraph()
Description copied from interface: GraphGenerator
Instructs the algorithm to generate the graph

Specified by:
generateGraph in interface GraphGenerator
Returns:
the generated graph

downIndex

protected int downIndex(int currentIndex,
                        int numSteps)
Determines the vertices with a smaller index that are in the neighborhood of currentIndex.

Parameters:
numSteps - indicates the number of steps away from the current index that are being considered.
currentIndex - the index of the selected vertex.

upIndex

protected int upIndex(int currentIndex,
                      int numSteps)
Determines the index of the neighbor ksteps above

Parameters:
numSteps - is the number of steps away from the current index that is being considered.
currentIndex - the index of the selected vertex.