void pruneNearlyIdenticalAngles ( ) { for ( int i = 0 ; i < listInfo . size ( ) ; i ++ ) { NodeInfo infoN = listInfo . get ( i ) ; for ( int j = 0 ; j < infoN . edges . size ( ) ; ) { int k = ( j + 1 ) % infoN . edges . size ; double angularDiff = UtilAngle . dist ( infoN . edges . get ( j ) . angle , infoN . edges . get ( k ) . angle ) ; if ( angularDiff < UtilAngle . radian ( 5 ) ) { NodeInfo infoJ = infoN . edges . get ( j ) . target ; NodeInfo infoK = infoN . edges . get ( k ) . target ; double distJ = infoN . ellipse . center . distance ( infoJ . ellipse . center ) ; double distK = infoN . ellipse . center . distance ( infoK . ellipse . center ) ; if ( distJ < distK ) { infoN . edges . remove ( k ) ; } else { infoN . edges . remove ( j ) ; } } else { j ++ ; } } } }
If there is a nearly perfect line a node farther down the line can come before . This just selects the closest