Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Edge getMinimalEdge(boolean[] included){
- int index1 = Integer.MAX_VALUE, index2 = Integer.MAX_VALUE;
- int minweight1 = Integer.MAX_VALUE; int minweight2 = Integer.MAX_VALUE;
- for(int i=0;i<this.num_nodes;i++){
- if(included[i]){
- //ako e vkluceno temeto i
- //izmini gi negovite nevkluceni sosedi
- Iterator<GraphNodeNeighbor<E>> it = adjList[i].getNeighbors().iterator();
- while(it.hasNext()){
- GraphNodeNeighbor<E> pom = it.next();
- //ako sosedot ne e poseten i ima do sega najmala tezina
- if(!included[pom.node.getIndex()] && pom.weight1<minweight1){
- index1 = i;
- index2 = pom.node.getIndex();
- minweight1 = pom.weight1;
- minweight2 = pom.weight2;
- }
- else if(!included[pom.node.getIndex()] && pom.weight1==minweight1){
- if(pom.weight2 < minweight2){
- index1 = i;
- index2 = pom.node.getIndex();
- minweight2 = pom.weight2;
- }
- }
- }
- }
- }
- if(minweight1<Integer.MAX_VALUE){
- Edge ret = new Edge(index1, index2, minweight1, minweight2);
- return ret;
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement