Class GridGenerator


public class GridGenerator extends AbstractGraphGenerator
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
  • Constructor Details

    • GridGenerator

      public GridGenerator(int rows, int cols)
      Parameters:
      rows - the number of rows.
      cols - the number of columns.
  • Method Details

    • createGraph

      public Graph createGraph()
      Vertices are numbered from left to right and from top to bottom.
      Returns:
      a grid graph.
    • createDigraph

      public Digraph createDigraph()
      Edges are oriented from left to right and top to bottom.
      Returns:
      a directed grid graph.