Skip to content

Commit d471681

Browse files
committed
Aplica black ao flouyd_warshall.py
1 parent aae0fce commit d471681

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/python/floyd_warshall.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@
44

55
from math import inf
66

7-
def gerar_matriz (n_linhas, n_colunas):
8-
return [[0]*n_colunas for _ in range(n_linhas)]
7+
8+
def gerar_matriz(n_linhas, n_colunas):
9+
return [[0] * n_colunas for _ in range(n_linhas)]
10+
911

1012
def imprime(matriz, vertices):
1113
print(' ', end='')
1214
for i in range(vertices):
13-
print(" ",i + 1,end='')
15+
print(" ", i + 1, end='')
1416
print('')
1517
for i in range(vertices):
1618
print(i + 1, matriz[i])
1719

20+
1821
def floyd_warshall(matriz, vertices):
1922
dist = gerar_matriz(vertices, vertices)
2023
# inicializando a matriz com infinito nas diagonais e as distancias das arestas
2124
for i in range(vertices):
2225
for j in range(vertices):
23-
if(i != j):
24-
if(matriz[i][j] != 0):
26+
if i != j:
27+
if matriz[i][j] != 0:
2528
dist[i][j] = matriz[i][j]
2629
else:
2730
dist[i][j] = inf
@@ -32,19 +35,21 @@ def floyd_warshall(matriz, vertices):
3235
for i in range(vertices):
3336
for j in range(vertices):
3437
Dist = inf
35-
if(dist[i][k] != inf or dist[k][j] != inf):
38+
if dist[i][k] != inf or dist[k][j] != inf:
3639
Dist = dist[i][k] + dist[k][j]
37-
38-
if(i != j and Dist != inf and Dist < dist[i][j]):
40+
41+
if i != j and Dist != inf and Dist < dist[i][j]:
3942
dist[i][j] = Dist
4043
# printando o resultado
4144
print('Matriz de distâncias')
4245
imprime(dist, vertices)
4346

47+
4448
def main():
45-
grafo = [[0,3,4,0],[0,0,0,5],[0,0,0,3],[8,0,0,0]]
49+
grafo = [[0, 3, 4, 0], [0, 0, 0, 5], [0, 0, 0, 3], [8, 0, 0, 0]]
4650
vertices = 4
4751
floyd_warshall(grafo, vertices)
4852

49-
if __name__ == "__main__" :
53+
54+
if __name__ == "__main__":
5055
main()

0 commit comments

Comments
 (0)