boolean addToRow ( SquareNode n , int corner , int sign , boolean skip , List < SquareNode > row ) { SquareEdge e ; while ( ( e = n . edges [ corner ] ) != null ) { if ( e . a == n ) { n = e . b ; corner = e . sideB ; } else { n = e . a ; corner = e . sideA ; } if ( ! skip ) { if ( n . graph != SquareNode . RESET_GRAPH ) { // This should never happen in a valid grid. It can happen if two nodes link to each other multiple // times. Other situations as well invalid = true ; return false ; } n . graph = 0 ; row . add ( n ) ; } skip = ! skip ; sign *= - 1 ; corner = addOffset ( corner , sign , n . square . size ( ) ) ; } return true ; }
Given a node and the corner to the next node down the line add to the list every other node until it hits the end of the row .