public Pair<Connection,Connection> findBestConnection(Block block,int radiusConnectionWS){
  Connection potentialBlockConnection=null;
  Connection potentialCompatibleConnection=null;
  List<Connection> blockConnections=block.getAllConnections();
  Connection curBlockConnection;
  Connection curCompatibleConnection;
  double maxSearchRadius=radiusConnectionWS;
  for (int i=0; i < blockConnections.size(); i++) {
    curBlockConnection=blockConnections.get(i);
    curCompatibleConnection=closestConnection(curBlockConnection,maxSearchRadius);
    if (curCompatibleConnection != null) {
      potentialBlockConnection=curBlockConnection;
      potentialCompatibleConnection=curCompatibleConnection;
      maxSearchRadius=potentialBlockConnection.distanceFrom(potentialCompatibleConnection);
    }
  }
  if (potentialBlockConnection == null) {
    return null;
  }
  return new Pair<>(potentialBlockConnection,potentialCompatibleConnection);
}

public Pair < Connection , Connection > findBestConnection ( Block block , int radiusConnectionWS ) { Connection potentialBlockConnection = null ; Connection potentialCompatibleConnection = null ; List < Connection > blockConnections = block . getAllConnections ( ) ; Connection curBlockConnection ; Connection curCompatibleConnection ; double maxSearchRadius = radiusConnectionWS ; for ( int i = 0 ; i < blockConnections . size ( ) ; i ++ ) { curBlockConnection = blockConnections . get ( i ) ; curCompatibleConnection = closestConnection ( curBlockConnection , maxSearchRadius ) ; if ( curCompatibleConnection != null ) { potentialBlockConnection = curBlockConnection ; potentialCompatibleConnection = curCompatibleConnection ; maxSearchRadius = potentialBlockConnection . distanceFrom ( potentialCompatibleConnection ) ; } } if ( potentialBlockConnection == null ) { return null ; } return new Pair < > ( potentialBlockConnection , potentialCompatibleConnection ) ; }
iterate over all of the connections on the block and find the one that is closest to a valid connection on another block .
