Package org.graph4j.generators
Class GridGenerator
java.lang.Object
org.graph4j.generators.AbstractGraphGenerator
org.graph4j.generators.GridGenerator
A two-dimensional m x n grid graph is the Cartesian product of the path
graphs Pm and Pn (m is the number of rows, n is the number of columns).
A planar embedding of a m x n grid graph is represented by the graph with
vertices corresponding to points at coordinates (x,y), x=1,...,m and
y=1,...,n, and edges connecting vertices whose points are at distance 1.
The grid graph is sometimes denoted L(m,n). It has has mn vertices and
(m-1)n+(n-1)m=2mn-m-n edges.
Vertices are numbered from left to right and from top to bottom.
- Author:
- Cristian Frăsinaru
-
Field Summary
Fields inherited from class org.graph4j.generators.AbstractGraphGenerator
vertices -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionEdges are oriented from left to right and top to bottom.Vertices are numbered from left to right and from top to bottom.Methods inherited from class org.graph4j.generators.AbstractGraphGenerator
addRandomEdges
-
Constructor Details
-
GridGenerator
public GridGenerator(int rows, int cols) - Parameters:
rows- the number of rows.cols- the number of columns.
-
-
Method Details
-
createGraph
Vertices are numbered from left to right and from top to bottom.- Returns:
- a grid graph.
-
createDigraph
Edges are oriented from left to right and top to bottom.- Returns:
- a directed grid graph.
-