File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -17,19 +17,22 @@ int minDistance(int dist[], Boolean sptSet[]) {
1717 // Iniciando um valor minimo
1818 int min = Integer .MAX_VALUE , min_index = -1 ;
1919
20- for (int v = 0 ; v < V ; v ++)
20+ for (int v = 0 ; v < V ; v ++) {
2121 if (sptSet [v ] == false && dist [v ] <= min ) {
2222 min = dist [v ];
2323 min_index = v ;
2424 }
25+ }
2526
2627 return min_index ;
2728 }
2829
2930 // Uma função de utilidade para imprimir a matriz de distância construída
3031 void printSolution (int dist []) {
3132 System .out .println ("Vertex \t \t Distance from Source" );
32- for (int i = 0 ; i < V ; i ++) System .out .println (i + " \t \t " + dist [i ]);
33+ for (int i = 0 ; i < V ; i ++) {
34+ System .out .println (i + " \t \t " + dist [i ]);
35+ }
3336 }
3437
3538 // Função que implementa o caminho mais curto da fonte única de Dijkstra
@@ -72,7 +75,9 @@ void dijkstra(int graph[][], int src) {
7275 if (!sptSet [v ]
7376 && graph [u ][v ] != 0
7477 && dist [u ] != Integer .MAX_VALUE
75- && dist [u ] + graph [u ][v ] < dist [v ]) dist [v ] = dist [u ] + graph [u ][v ];
78+ && dist [u ] + graph [u ][v ] < dist [v ]) {
79+ dist [v ] = dist [u ] + graph [u ][v ];
80+ }
7681 }
7782
7883 // imprime a matriz de distância construída
You can’t perform that action at this time.
0 commit comments