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>
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
-
Method Summary
Modifier and TypeMethodDescriptioncreateNetwork
(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)
-
Constructor Details
-
Lattice2DGenerator
public Lattice2DGenerator(boolean isToroidal) Creates a Lattice2DGenerator.- Parameters:
isToroidal
- whether lattice wraps or not.
-
-
Method Details
-
createNetwork
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)
-