Class Lattice2DGenerator<T>

java.lang.Object
repast.simphony.context.space.graph.AbstractGenerator<T>
repast.simphony.context.space.graph.Lattice2DGenerator<T>
All Implemented Interfaces:
NetworkGenerator<T>

public class Lattice2DGenerator<T> extends AbstractGenerator<T>
Generator for n x n lattice where each vertex is incident with its four neighbors except perhaps for the edge vertices depending on whether the lattice is toroidal.

Based on code from the Jung project.

Author:
Nick Collier, Jung Project
  • Constructor Details

    • Lattice2DGenerator

      public Lattice2DGenerator(boolean isToroidal)
      Creates a Lattice2DGenerator.
      Parameters:
      isToroidal - whether lattice wraps or not.
  • Method Details

    • createNetwork

      public Network<T> createNetwork(Network<T> network)
      Given an existing network, add edges to create a 2D lattice. The lattice dimension n is the square root of the number of nodes in the specified network. The resulting lattice will be nxn.
      Parameters:
      network - the network to rewire
      Returns:
      the created network
    • upIndex

      protected int upIndex(int currentLatticeRow, int currentLatticeColumn)
    • downIndex

      protected int downIndex(int currentLatticeRow, int currentLatticeColumn)
    • leftIndex

      protected int leftIndex(int currentLatticeRow, int currentLatticeColumn)
    • rightIndex

      protected int rightIndex(int currentLatticeRow, int currentLatticeColumn)