private void drawconn(Graphics g,int[][] X,int[][] Y,int xd,int yd,double[][] w, double thresh) 
 {
  for (int j=0;j<yd;j++)
   {
    for (int i=0;i<xd;i++)
     { 
      if (!showOK(i,j)) continue;
      double st=Math.abs(w[j][i]);
      double tt=0;
      if (st==0) continue;
      if (w[j][i]<0) g.setColor(Color.blue);
               else  g.setColor(Color.red);
      if (thresh==0) tt=Math.log(st+1)/Math.log(Math.exp(1)); 
      else tt=Math.log(st/thresh)/Math.log(Math.exp(1)); // log2 of st
      int htness=(int)(tt+.5);
      if (tt<0) htness=-1;
      if (tt>5) htness=5;

      //if (st>=thresh)
      for (int t=-1;t<htness;t++)
       g.drawLine(X[i][0]+t,X[i][1],Y[j][0]+t,Y[j][2]);

     }
     
   }
 }