void NNItopSwitch( edge e, direction d, double[][] A )
	{
		edge par, fixed;
		edge skew, swap;
	  
		if ( direction.LEFT == d )
			swap = e.head.leftEdge;
		else
			swap = e.head.rightEdge;
		skew = e.siblingEdge();
		fixed = swap.siblingEdge();
	  	par = e.tail.parentEdge;
	  	/*perform topological switch by changing f from (u,b) to (v,b)
	    	and g from (v,c) to (u,c), necessitates also changing parent fields*/
	  	swap.tail = e.tail;
	  	skew.tail = e.head;
	  
	  	if ( direction.LEFT == d )
	  		e.head.leftEdge = skew;
	  	else
	  		e.head.rightEdge = skew;
	  	if (skew == e.tail.rightEdge)
	  		e.tail.rightEdge = swap;
	  	else
	  		e.tail.leftEdge = swap;
	  	//both topsize and bottomsize change for e, but nowhere else
	  	e.topsize = par.topsize + swap.bottomsize;
	  	e.bottomsize = fixed.bottomsize + skew.bottomsize;
	  	NNIupdateAverages( A, e, par, skew, swap, fixed );
	}