extension/src/main/java/org/justinnk/masonssa/extension/graphs/GridGraphCreator.java
/**
   * Connect the nodes found in network according to a von-Neumann-neighbourhood. <br>
   * <b>Important Note 1</b>: This is for use with an undirected graph, where the direction of edges
   * does not matter. For information: the edges are directed bottom to top and left to right. <br>
   * <b>Important Note 2</b>: All weights are set to 1.0
   *
   * @param network The network to build the graph with. Has to already contain the nodes.
   */
Connect the nodes found in network according to a von-Neumann-neighbourhood. 
Important Note 1: This is for use with an undirected graph, where the direction of edges
does not matter. For information: the edges are directed bottom to top and left to right. 
Important Note 2: All weights are set to 1.0

@param network The network to build the graph with. Has to already contain the nodes.
Connect the nodes found in network according to a von - Neumann - neighbourhood . Important Note 1 : This is for use with an undirected graph where the direction of edges does not matter . For information : the edges are directed bottom to top and left to right . Important Note 2 : All weights are set to 1 . 0 @param network The network to build the graph with . Has to already contain the nodes .
@Override
  public void create(Network network) {
    Bag nodes = network.getAllNodes();
    int size = nodes.size();
    int rows = (int) Math.sqrt(size);
    for (int i = 0; i < size; i++) {
      Object node = nodes.get(i);
      /* If we are not the first node of this row */
      if (i > 0 && i % rows != 0) {
        /* connect us to our neighbour above */
        Object nodeT = nodes.get(i - 1);
        network.addEdge(node, nodeT, 1.0);
      }
      /* If we are not in the last row */
      if (i + rows < size) {
        /* connect us to our neighbour on the right */
        Object nodeR = nodes.get(i + rows);
        network.addEdge(node, nodeR, 1.0);
      }
    }
  }
@ Override public void create ( Network network ) { Bag nodes = network . getAllNodes ( ) ; int size = nodes . size ( ) ; int rows = ( int ) Math . sqrt ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { Object node = nodes . get ( i ) ; /* If we are not the first node of this row */ if ( i > 0 && i % rows != 0 ) { /* connect us to our neighbour above */ Object nodeT = nodes . get ( i - 1 ) ; network . addEdge ( node , nodeT , 1.0 ) ; } /* If we are not in the last row */ if ( i + rows < size ) { /* connect us to our neighbour on the right */ Object nodeR = nodes . get ( i + rows ) ; network . addEdge ( node , nodeR , 1.0 ) ; } } }
Connect the nodes found in network according to a von-Neumann-neighbourhood.
Connect the nodes found in network according to a von - Neumann - neighbourhood .