Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. private Edge getMinimalEdge(boolean[] included){
  2. int index1 = Integer.MAX_VALUE, index2 = Integer.MAX_VALUE;
  3. int minweight1 = Integer.MAX_VALUE; int minweight2 = Integer.MAX_VALUE;
  4.  
  5. for(int i=0;i<this.num_nodes;i++){
  6. if(included[i]){
  7. //ako e vkluceno temeto i
  8. //izmini gi negovite nevkluceni sosedi
  9. Iterator<GraphNodeNeighbor<E>> it = adjList[i].getNeighbors().iterator();
  10. while(it.hasNext()){
  11. GraphNodeNeighbor<E> pom = it.next();
  12. //ako sosedot ne e poseten i ima do sega najmala tezina
  13. if(!included[pom.node.getIndex()] && pom.weight1<minweight1){
  14. index1 = i;
  15. index2 = pom.node.getIndex();
  16. minweight1 = pom.weight1;
  17. minweight2 = pom.weight2;
  18. }
  19. else if(!included[pom.node.getIndex()] && pom.weight1==minweight1){
  20. if(pom.weight2 < minweight2){
  21. index1 = i;
  22. index2 = pom.node.getIndex();
  23. minweight2 = pom.weight2;
  24. }
  25. }
  26. }
  27. }
  28. }
  29.  
  30. if(minweight1<Integer.MAX_VALUE){
  31. Edge ret = new Edge(index1, index2, minweight1, minweight2);
  32. return ret;
  33. }
  34. return null;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement