private void growCluster ( List < ChessboardCorner > corners , int seedIdx , ChessboardCornerGraph graph ) { // open contains corner list indexes open . add ( seedIdx ) ; while ( open . size > 0 ) { int cornerIdx = open . pop ( ) ; Vertex v = vertexes . get ( cornerIdx ) ; // make sure it hasn't already been processed if ( v . marked ) continue ; v . marked = true ; // Create the node in the output cluster for this corner ChessboardCornerGraph . Node gn = graph . growCorner ( ) ; c2n . data [ cornerIdx ] = gn . index ; n2c . data [ gn . index ] = cornerIdx ; gn . set ( corners . get ( cornerIdx ) ) ; // Add to the open list all the edges which haven't been processed yet; for ( int i = 0 ; i < v . connections . size ( ) ; i ++ ) { Vertex dst = v . connections . get ( i ) . dst ; if ( dst . marked ) continue ; open . add ( dst . index ) ; } } }
Given the initial seed add all connected nodes to the output cluster while keeping track of how to convert one node index into another one between the two graphs