public class Lattice2DGenerator<V,E> extends Object implements GraphGenerator<V,E>
If the graph Supplier supplied has a default edge type of EdgeType.DIRECTED
,
then edges will be created in both directions between adjacent vertices.
Modifier and Type | Field and Description |
---|---|
protected int |
col_count |
protected com.google.common.base.Supplier<E> |
edge_factory |
protected com.google.common.base.Supplier<? extends Graph<V,E>> |
graph_factory |
protected boolean |
is_directed |
protected boolean |
is_toroidal |
protected int |
row_count |
protected com.google.common.base.Supplier<V> |
vertex_factory |
Constructor and Description |
---|
Lattice2DGenerator(com.google.common.base.Supplier<? extends Graph<V,E>> graph_factory,
com.google.common.base.Supplier<V> vertex_factory,
com.google.common.base.Supplier<E> edge_factory,
int latticeSize,
boolean isToroidal)
Constructs a generator of square lattices of size
latticeSize
with the specified parameters. |
Lattice2DGenerator(com.google.common.base.Supplier<? extends Graph<V,E>> graph_factory,
com.google.common.base.Supplier<V> vertex_factory,
com.google.common.base.Supplier<E> edge_factory,
int row_count,
int col_count,
boolean isToroidal)
Creates a generator of
row_count x col_count lattices
with the specified parameters. |
Modifier and Type | Method and Description |
---|---|
Graph<V,E> |
get()
Generates a graph based on the constructor-specified settings.
|
protected int |
getCol(int i) |
int |
getGridEdgeCount()
Returns the number of edges found in a lattice of this generator's specifications.
|
protected int |
getIndex(int i,
int j) |
protected int |
getRow(int i) |
protected V |
getVertex(int i) |
protected V |
getVertex(int i,
int j) |
protected int |
mod(int i,
int modulus) |
protected int row_count
protected int col_count
protected boolean is_toroidal
protected boolean is_directed
protected com.google.common.base.Supplier<V> vertex_factory
protected com.google.common.base.Supplier<E> edge_factory
public Lattice2DGenerator(com.google.common.base.Supplier<? extends Graph<V,E>> graph_factory, com.google.common.base.Supplier<V> vertex_factory, com.google.common.base.Supplier<E> edge_factory, int latticeSize, boolean isToroidal)
latticeSize
with the specified parameters.graph_factory
- used to create the Graph
for the latticevertex_factory
- used to create the lattice verticesedge_factory
- used to create the lattice edgeslatticeSize
- the number of rows and columns of the latticeisToroidal
- if true, the created lattice wraps from top to bottom and left to rightpublic Lattice2DGenerator(com.google.common.base.Supplier<? extends Graph<V,E>> graph_factory, com.google.common.base.Supplier<V> vertex_factory, com.google.common.base.Supplier<E> edge_factory, int row_count, int col_count, boolean isToroidal)
row_count
x col_count
lattices
with the specified parameters.graph_factory
- used to create the Graph
for the latticevertex_factory
- used to create the lattice verticesedge_factory
- used to create the lattice edgesrow_count
- the number of rows in the latticecol_count
- the number of columns in the latticeisToroidal
- if true, the created lattice wraps from top to bottom and left to rightpublic int getGridEdgeCount()
protected int getIndex(int i, int j)
protected int mod(int i, int modulus)
protected V getVertex(int i, int j)
i
- row index into the latticej
- column index into the latticei mod row_count, j mod col_count
)protected V getVertex(int i)
i
- row index into the latticei
th vertex (counting row-wise)protected int getRow(int i)
i
- index of the vertex whose row we wanti
is foundprotected int getCol(int i)
i
- index of the vertex whose column we wanti
is foundCopyright © 2015. All rights reserved.