Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. 0 0 0 0 0 12 13 0
  2. 0 0 6 0 0 0 0 3
  3. 0 6 0 4 0 0 0 5
  4. 0 0 4 0 10 0 0 7
  5. 0 0 0 10 0 11 8 9
  6. 12 0 0 0 11 0 1 0
  7. 13 0 0 0 8 1 0 2
  8. 0 3 5 7 9 0 2 0
  9.  
  10. 0 0 0 0 0 0 0 0
  11. 0 0 0 0 0 0 0 0
  12. 0 0 0 0 0 0 0 0
  13. 0 0 0 0 0 0 0 0
  14. 0 0 0 0 0 0 0 0
  15. 0 0 0 0 0 0 1 0
  16. 0 0 0 0 0 1 0 0
  17. 0 0 0 0 0 0 0 0
  18.  
  19. int numVerts = G.length;
  20. int [][] H = new int[numVerts][numVerts];
  21. while (/*there exists an empty row in H*/){
  22. for (int i = 0; i < numVerts; i++){
  23. for (int j = 0; j < numVerts; j++){
  24. if ((G[i][j] != 0) && (G[i][j] < minWeight)){
  25. minWeight = G[i][j];
  26. k = i;
  27. l = j;
  28. }
  29. }
  30. }
  31. H[k][l] = minWeight;
  32. H[l][k] = minWeight;
  33. G[k][l] = 0;
  34. G[l][k] = 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement