direction bNNIEdgeTest( edge e, double[][] A, double[] weight, int wPos )
	{
	  	edge f;
	  	double D_LR, D_LU, D_LD, D_RD, D_RU, D_DU;
	  	double w1,w2,w0;
	  	if ( e.tail.leaf() || e.head.leaf() )
	    	return direction.NONE;
	  	f = e.siblingEdge();
	  	D_LR = A[e.head.leftEdge.head.index][e.head.rightEdge.head.index];
	  	D_LU = A[e.head.leftEdge.head.index][e.tail.index];
	  	D_LD = A[e.head.leftEdge.head.index][f.head.index];
	  	D_RU = A[e.head.rightEdge.head.index][e.tail.index];
	  	D_RD = A[e.head.rightEdge.head.index][f.head.index];
	  	D_DU = A[e.tail.index][f.head.index];

	  	w0 = wf5(D_RU,D_LD,D_LU,D_RD,D_DU,D_LR); //weight of current config
	  	w1 = wf5(D_RU,D_LD,D_DU,D_LR,D_LU,D_RD); //weight with L<.D switch
	  	w2 = wf5(D_DU,D_LR,D_LU,D_RD,D_RU,D_LD); //weight with R<.D switch
	  	if ( w0 <= w1 )
	    {
	  		if (w0 <= w2) // w0 <= w1,w2
			{
	  			weight[wPos] = 0.0;
	  			return direction.NONE;
			}
	  		else // w2 < w0 <= w1 
	  		{
	  			weight[wPos] = w2 - w0;
	  			return direction.RIGHT;
	  		}
	    }
	  	else if (w2 <= w1) // w2 <= w1 < w0
	    {
	  		weight[wPos] = w2 - w0;
	      	return direction.RIGHT;
	    }
	  	else // w1 < w2, w0
	    {
	  		weight[wPos] = w1 - w0;
	      	return direction.LEFT;	
	    }
	}