private void priorityLayout2(int level[], int priorities[], int bCenters[], int horPositions[]) { int descOrder[] = new int[priorities.length];   descOrder[0]=0; for(int i=0; i<priorities.length-1; i++) { int j=i; int temp=i+1;  while( j>-1 && priorities[descOrder[j]]<priorities[temp] ) { descOrder[j+1] = descOrder[j]; j--; } j++; descOrder[j] = temp; }         for(int k=0; k<descOrder.length; k++) for(int i=0; i<descOrder.length; i++) {  int leftCount=0, rightCount=0, leftNodes[], rightNodes[]; for(int j=0; j<priorities.length; j++) { if( horPositions[level[descOrder[i]]] > horPositions[level[j]] ) leftCount++; else if( horPositions[level[descOrder[i]]] < horPositions[level[j]] ) rightCount++; } leftNodes = new int[leftCount]; rightNodes = new int[rightCount];  for(int j=0, l=0, r=0; j<priorities.length; j++) if( horPositions[level[descOrder[i]]] > horPositions[level[j]] ) leftNodes[l++]=j; else if( horPositions[level[descOrder[i]]] < horPositions[level[j]] ) rightNodes[r++]=j;    while( Math.abs(horPositions[level[descOrder[i]]]-1-bCenters[descOrder[i]]) < Math.abs(horPositions[level[descOrder[i]]]-bCenters[descOrder[i]]) ) {   int temp = horPositions[level[descOrder[i]]]; boolean cantMove=false;  for(int j=leftNodes.length-1; j>=0; j--) { if(temp-horPositions[level[leftNodes[j]]] > 1) break; else if(priorities[descOrder[i]]<=priorities[leftNodes[j]]) { cantMove=true; break; } else temp = horPositions[level[leftNodes[j]]]; }   if(cantMove) break;  temp = horPositions[level[descOrder[i]]]-1;  for(int j=leftNodes.length-1; j>=0; j--) { if(temp==horPositions[level[leftNodes[j]]]) {   horPositions[level[leftNodes[j]]] = temp = horPositions[level[leftNodes[j]]]-1; }  }    horPositions[level[descOrder[i]]] = horPositions[level[descOrder[i]]]-1; }   while( Math.abs(horPositions[level[descOrder[i]]]+1-bCenters[descOrder[i]]) < Math.abs(horPositions[level[descOrder[i]]]-bCenters[descOrder[i]]) ) {  int temp = horPositions[level[descOrder[i]]]; boolean cantMove=false;  for(int j=0; j<rightNodes.length; j++) { if(horPositions[level[rightNodes[j]]]-temp > 1) break; else if(priorities[descOrder[i]]<=priorities[rightNodes[j]]) { cantMove=true; break; } else temp = horPositions[level[rightNodes[j]]]; }   if(cantMove) break;  temp = horPositions[level[descOrder[i]]]+1;  for(int j=0; j<rightNodes.length; j++) { if(temp==horPositions[level[rightNodes[j]]]) {   horPositions[level[rightNodes[j]]] = temp = horPositions[level[rightNodes[j]]]+1; } }    horPositions[level[descOrder[i]]] = horPositions[level[descOrder[i]]]+1; } }
private void priorityLayout2(int level[], int priorities[], int bCenters[], int horPositions[]) { int descOrder[] = new int[priorities.length];   descOrder[0]=0; for(int i=0; i<priorities.length-1; i++) { int j=i; int temp=i+1;  while( j>-1 && priorities[descOrder[j]]<priorities[temp] ) { descOrder[j+1] = descOrder[j]; j--; } j++; descOrder[j] = temp;
    private void priorityLayout2(int level[], int priorities[], int bCenters[], int horPositions[]) {	int descOrder[] = new int[priorities.length];	//Getting the indices of priorities in descending order	descOrder[0]=0;	for(int i=0; i<priorities.length-1; i++) {	    int j=i;	    int temp=i+1;	    	    while( j>-1 && priorities[descOrder[j]]<priorities[temp] ) {		descOrder[j+1] = descOrder[j];		j--;	    }	    j++;	    descOrder[j] = temp;	}		//System.out.println("\nPriorities:");	//for(int i=0; i<priorities.length; i++)	//    System.out.print(priorities[i]+" ");	//System.out.println("\nDescOrder:");	//for(int i=0; i<descOrder.length; i++)	//    System.out.print(descOrder[i]+" ");	for(int k=0; k<descOrder.length; k++)	    for(int i=0; i<descOrder.length; i++) {				int leftCount=0, rightCount=0, leftNodes[], rightNodes[];		for(int j=0; j<priorities.length; j++) {		    if( horPositions[level[descOrder[i]]] > horPositions[level[j]] )			leftCount++;		    else if( horPositions[level[descOrder[i]]] < horPositions[level[j]] )			rightCount++;		}		leftNodes = new int[leftCount];		rightNodes = new int[rightCount];		for(int j=0, l=0, r=0; j<priorities.length; j++)		    if( horPositions[level[descOrder[i]]] > horPositions[level[j]] )			leftNodes[l++]=j;		    else if( horPositions[level[descOrder[i]]] < horPositions[level[j]] )			rightNodes[r++]=j;						//****Moving left	    		while( Math.abs(horPositions[level[descOrder[i]]]-1-bCenters[descOrder[i]]) < 		       Math.abs(horPositions[level[descOrder[i]]]-bCenters[descOrder[i]]) ) {		    		    //****Checking if it can be moved to left		    int temp = horPositions[level[descOrder[i]]];		    boolean cantMove=false;		    		    for(int j=leftNodes.length-1; j>=0; j--) {			if(temp-horPositions[level[leftNodes[j]]] > 1)			    break;			else if(priorities[descOrder[i]]<=priorities[leftNodes[j]])			    { cantMove=true; break; }			else			    temp = horPositions[level[leftNodes[j]]];		    }		    //if(horPositions[level[descOrder[i]]]-1==horPositions[level[leftNodes[j]]])		    //    cantMove = true;		    if(cantMove)			break;		    		    temp = horPositions[level[descOrder[i]]]-1;		    //****moving other vertices to left		    for(int j=leftNodes.length-1; j>=0; j--) {			if(temp==horPositions[level[leftNodes[j]]])			    {   //System.out.println("Moving "+((Node)m_nodes.elementAt(level[leftNodes[j]])).ID+" from "				//		  +horPositions[level[leftNodes[j]]]+" to "				//		  +(horPositions[level[leftNodes[j]]]-1) );				horPositions[level[leftNodes[j]]] = temp = horPositions[level[leftNodes[j]]]-1; }					    }		    //System.out.println("Moving main "+((GraphNode)m_nodes.elementAt(level[descOrder[i]])).ID+" from "		    //		       +horPositions[level[descOrder[i]]]+" to "		    //		       +(horPositions[level[descOrder[i]]]-1));					    		    horPositions[level[descOrder[i]]] = horPositions[level[descOrder[i]]]-1;		}				//****Moving right		while( Math.abs(horPositions[level[descOrder[i]]]+1-bCenters[descOrder[i]]) < 		       Math.abs(horPositions[level[descOrder[i]]]-bCenters[descOrder[i]]) ) {		    //****checking if the vertex can be moved		    int temp = horPositions[level[descOrder[i]]];		    boolean cantMove=false;		    		    for(int j=0; j<rightNodes.length; j++) {			if(horPositions[level[rightNodes[j]]]-temp > 1)			    break;			else if(priorities[descOrder[i]]<=priorities[rightNodes[j]])			    { cantMove=true; break; }			else			    temp = horPositions[level[rightNodes[j]]];		    }		    //if(horPositions[level[descOrder[i]]]-1==horPositions[level[leftNodes[j]]])		    //    cantMove = true;		    if(cantMove)			break;		    		    temp = horPositions[level[descOrder[i]]]+1;		    //****moving other vertices to left		    for(int j=0; j<rightNodes.length; j++) {			if(temp==horPositions[level[rightNodes[j]]])			    {   //System.out.println("Moving "+((Node)m_nodes.elementAt(level[rightNodes[j]])).ID+" from "				//			+horPositions[level[rightNodes[j]]]+" to "				//		+(horPositions[level[rightNodes[j]]]+1) );				horPositions[level[rightNodes[j]]] = temp = horPositions[level[rightNodes[j]]]+1; }		    }		    //System.out.println("Moving main "+((GraphNode)m_nodes.elementAt(level[descOrder[i]])).ID+" from "		    //		       +horPositions[level[descOrder[i]]]+" to "		    //		       +(horPositions[level[descOrder[i]]]+1));		    horPositions[level[descOrder[i]]] = horPositions[level[descOrder[i]]]+1;		}	    }    }