Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 0 0 0 0 0 12 13 0
- 0 0 6 0 0 0 0 3
- 0 6 0 4 0 0 0 5
- 0 0 4 0 10 0 0 7
- 0 0 0 10 0 11 8 9
- 12 0 0 0 11 0 1 0
- 13 0 0 0 8 1 0 2
- 0 3 5 7 9 0 2 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 1 0
- 0 0 0 0 0 1 0 0
- 0 0 0 0 0 0 0 0
- int numVerts = G.length;
- int [][] H = new int[numVerts][numVerts];
- while (/*there exists an empty row in H*/){
- for (int i = 0; i < numVerts; i++){
- for (int j = 0; j < numVerts; j++){
- if ((G[i][j] != 0) && (G[i][j] < minWeight)){
- minWeight = G[i][j];
- k = i;
- l = j;
- }
- }
- }
- H[k][l] = minWeight;
- H[l][k] = minWeight;
- G[k][l] = 0;
- G[l][k] = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement