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
-
-
Field Summary
-
Fields inherited from class repast.simphony.context.space.graph.AbstractGenerator
msg
-
-
Constructor Summary
Constructors Constructor Description Lattice2DGenerator(boolean isToroidal)
Creates a Lattice2DGenerator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Network<T>
createNetwork(Network<T> network)
Given an existing network, add edges to create a 2D lattice.protected int
downIndex(int currentLatticeRow, int currentLatticeColumn)
protected int
leftIndex(int currentLatticeRow, int currentLatticeColumn)
protected int
rightIndex(int currentLatticeRow, int currentLatticeColumn)
protected int
upIndex(int currentLatticeRow, int currentLatticeColumn)
-
-
-
Method Detail
-
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)
-
-