void disconnectSingleConnections ( ) { List < SquareNode > open = new ArrayList <> ( ) ; List < SquareNode > open2 = new ArrayList <> ( ) ; for ( int i = 0 ; i < nodes . size ( ) ; i ++ ) { SquareNode n = nodes . get ( i ) ; checkDisconnectSingleEdge ( open , n ) ; } while ( ! open . isEmpty ( ) ) { for ( int i = 0 ; i < open . size ( ) ; i ++ ) { SquareNode n = open . get ( i ) ; checkDisconnectSingleEdge ( open2 , n ) ; open . clear ( ) ; List < SquareNode > tmp = open ; open = open2 ; open2 = tmp ; } } }
Nodes that have only a single connection to one other node are disconnected since they are likely to be noise . This is done recursively