float rowBC[]; rowBC = calcRowBC(lindex, levels);   for(int i=0; i<rowBC.length-1; i++) { if(rowBC[i]==rowBC[i+1]) {  int tempLevels[][] = new int[levels.length][]; copy2DArray(levels, tempLevels);    int node1 = levels[lindex][i]; int node2 = levels[lindex][i+1]; levels[lindex][i+1] = node1; levels[lindex][i] = node2;  for(int k=lindex-1; k>=0; k--) phaseIU(k, levels); if(crossings(levels)<=crossings(tempLevels)) { copy2DArray(levels, tempLevels); } else { copy2DArray(tempLevels, levels); levels[lindex][i+1] = node1; levels[lindex][i] = node2; }      for(int k=0; k<levels.length-1; k++) phaseID(k, levels);    if(crossings(tempLevels)<=crossings(levels)) copy2DArray(tempLevels, levels);    } }
float rowBC[]; rowBC = calcRowBC(lindex, levels);   for(int i=0; i<rowBC.length-1; i++) { if(rowBC[i]==rowBC[i+1]) {   int tempLevels[][] = new int[levels.length][]; copy2DArray(levels, tempLevels);     int node1 = levels[lindex][i]; int node2 = levels[lindex][i+1]; levels[lindex][i+1] = node1; levels[lindex][i] = node2;  for(int k=lindex-1; k>=0; k--) phaseIU(k, levels); if(crossings(levels)<=crossings(tempLevels)) {   copy2DArray(levels, tempLevels); } else { copy2DArray(tempLevels, levels); levels[lindex][i+1] = node1; levels[lindex][i] = node2; }        for(int k=0; k<levels.length-1; k++) phaseID(k, levels);     if(crossings(tempLevels)<=crossings(levels)) copy2DArray(tempLevels, levels);      }
     public void phaseIIU(final int lindex, final int levels[][]) {	float rowBC[];	rowBC = calcRowBC(lindex, levels);		//System.out.println("Getting into phaseIIU");      	for(int i=0; i<rowBC.length-1; i++) {	    if(rowBC[i]==rowBC[i+1]) {		//System.out.println("Crossings before begining of iteration: "+crossings(levels));		int tempLevels[][] = new int[levels.length][];		copy2DArray(levels, tempLevels);		//System.out.println("Interchanging: "+((GraphNode)m_nodes.elementAt(levels[lindex][i])).ID+" & "+		//		   ((GraphNode)m_nodes.elementAt(levels[lindex][i+1])).ID+		//		   " at level "+(lindex+1) );		int node1 = levels[lindex][i];		int node2 = levels[lindex][i+1];		levels[lindex][i+1] = node1;		levels[lindex][i] = node2;				for(int k=lindex-1; k>=0; k--)		    phaseIU(k, levels);		if(crossings(levels)<=crossings(tempLevels))		    { //System.out.println("Crossings temp: "+crossings(tempLevels)+" Crossings levels: "+crossings(levels));		      copy2DArray(levels, tempLevels); } //printMatrices(levels); 		else {		    copy2DArray(tempLevels, levels);		    levels[lindex][i+1] = node1;		    levels[lindex][i] = node2;		}		//System.out.println("Crossings after PhaseIU of PhaseIIU, in iteration "+i+" of "+(rowBC.length-1)+" at "		//		   +lindex+", levels: "+crossings(levels)+" temp: "+crossings(tempLevels));				//tempLevels = new int[levels.length][];		//copy2DArray(levels, tempLevels);		for(int k=0; k<levels.length-1; k++) //lindex-1; k++)		    phaseID(k, levels);		//if(crossings(tempLevels)<crossings(levels))		//    { //System.out.println("Crossings temp: "+crossings(tempLevels)+" Crossings levels: "+crossings(levels));		//      copy2DArray(tempLevels, levels); } //printMatrices(levels); }		if(crossings(tempLevels)<=crossings(levels))		    copy2DArray(tempLevels, levels);		//System.out.println("Crossings after PhaseID of phaseIIU, in iteration "+i+" of "+(rowBC.length-1)+" at "		//		   +lindex+", levels: "+crossings(levels)+" temp: "+crossings(tempLevels));		//rowBC = calcRowBC(lindex, levels);	    }	}    }