void GMEupdateAveragesMatrix( double[][] A, edge e, node v, node newNode )
	{
	  edge sib, par, left, right;
	  sib = e.siblingEdge();
	  left = e.head.leftEdge;
	  right = e.head.rightEdge;
	  par = e.tail.parentEdge;

	  /*we need to update the matrix A so all 1-distant, 2-distant, and
	    3-distant averages are correct*/
	  
	  /*first, initialize the newNode entries*/
	  /*1-distant*/
	  A[newNode.index][newNode.index] = 
	    (e.bottomsize*A[e.head.index][e.head.index]
	     + A[v.index][e.head.index])
	    / (e.bottomsize + 1);
	  /*1-distant for v*/
	  A[v.index][v.index] = 
	    (e.bottomsize*A[e.head.index][v.index] 
	     + e.topsize*A[v.index][e.head.index])
	    / (e.bottomsize + e.topsize);

	  /*2-distant for v,newNode*/
	  A[v.index][newNode.index] = A[newNode.index][v.index] = 
	    A[v.index][e.head.index];
	  
	  /*second 2-distant for newNode*/
	  A[newNode.index][e.tail.index] = A[e.tail.index][newNode.index]
	    = (e.bottomsize*A[e.head.index][e.tail.index]
	       + A[v.index][e.tail.index])/(e.bottomsize + 1);
	  /*third 2-distant for newNode*/
	  A[newNode.index][e.head.index] = A[e.head.index][newNode.index]
	    = A[e.head.index][e.head.index];
	   
	  if (null != sib)
	    {
	      /*fourth and last 2-distant for newNode*/
	      A[newNode.index][sib.head.index] =
		A[sib.head.index][newNode.index] = 
		(e.bottomsize*A[sib.head.index][e.head.index]
		 + A[sib.head.index][v.index]) / (e.bottomsize + 1);
	      updateSubTreeAverages(A,sib,v,direction.SKEW); /*updates sib and below*/
	    }
	  if (null != par)
	    {
	      if (e.tail.leftEdge == e)
		updateSubTreeAverages(A,par,v,direction.LEFT); /*updates par and above*/
	      else
		updateSubTreeAverages(A,par,v,direction.RIGHT);
	    }
	  if (null != left)
	    updateSubTreeAverages(A,left,v,direction.UP); /*updates left and below*/
	  if (null != right)
	    updateSubTreeAverages(A,right,v,direction.UP); /*updates right and below*/  

	  /*1-dist for e.head*/
	  A[e.head.index][e.head.index] = 
	    (e.topsize*A[e.head.index][e.head.index]
	     + A[e.head.index][v.index]) / (e.topsize+1);
	  /*2-dist for e.head (v,newNode,left,right)
	    taken care of elsewhere*/
	  /*3-dist with e.head either taken care of elsewhere (below)
	    or unchanged (sib,e.tail)*/
	  
	  /*symmetrize the matrix (at least for distant-2 subtrees) */
	  A[v.index][e.head.index] = A[e.head.index][v.index];
	  /*and distant-3 subtrees*/
	  A[e.tail.index][v.index] = A[v.index][e.tail.index];
	  if (null != left)
	    A[v.index][left.head.index] = A[left.head.index][v.index];
	  if (null != right)
	    A[v.index][right.head.index] = A[right.head.index][v.index];
	  if (null != sib)
	    A[v.index][sib.head.index] = A[sib.head.index][v.index];

	}