Class GridGraphGenerator<V,​E>

  • Type Parameters:
    V - the graph vertex type
    E - the graph edge type
    All Implemented Interfaces:
    GraphGenerator<V,​E,​V>

    public class GridGraphGenerator<V,​E>
    extends java.lang.Object
    implements GraphGenerator<V,​E,​V>
    Generates a bidirectional grid graph of any size. A grid graph is a two dimensional graph whose vertices correspond to the points in the plane with integer coordinates, x-coordinates being in the range 0,..., n, y-coordinates being in the range 1,...m, and two vertices are connected by an edge whenever the corresponding points are at distance 1. Vertices are created from left to right and from top to bottom.
    Author:
    Assaf Mizrachi
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CORNER_VERTEX
      Role for the vertices at the corners.
    • Constructor Summary

      Constructors 
      Constructor Description
      GridGraphGenerator​(int rows, int cols)
      Creates a new GridGraphGenerator object with rows x cols dimension.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void generateGraph​(Graph<V,​E> target, java.util.Map<java.lang.String,​V> resultMap)
      Generate a graph structure.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CORNER_VERTEX

        public static final java.lang.String CORNER_VERTEX
        Role for the vertices at the corners.
        See Also:
        Constant Field Values
    • Constructor Detail

      • GridGraphGenerator

        public GridGraphGenerator​(int rows,
                                  int cols)
        Creates a new GridGraphGenerator object with rows x cols dimension.
        Parameters:
        rows - the number of rows
        cols - the number of columns
    • Method Detail

      • generateGraph

        public void generateGraph​(Graph<V,​E> target,
                                  java.util.Map<java.lang.String,​V> resultMap)
        Generate a graph structure. The topology of the generated graph is dependent on the implementation. For graphs in which not all vertices share the same automorphism equivalence class, the generator may produce a labeling indicating the roles played by generated elements. This is the purpose of the resultMap parameter. For example, a generator for a wheel graph would designate a hub vertex. Role names used as keys in resultMap should be declared as public static final Strings by implementation classes.
        Specified by:
        generateGraph in interface GraphGenerator<V,​E,​V>
        Parameters:
        target - receives the generated edges and vertices; if this is non-empty on entry, the result will be a disconnected graph since generated elements will not be connected to existing elements
        resultMap - if non-null, receives implementation-specific mappings from String roles to graph elements (or collections of graph elements)