Skip to content

Commit 13e974e

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 7ae1534 commit 13e974e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

networking_flow/ford_fulkerson.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
[0, 0, 0, 0, 0, 0],
88
]
99

10+
1011
def breadth_first_search(graph: list, source: int, sink: int, parents: list) -> bool:
1112
"""
1213
This function returns True if there is a node that has not iterated.
@@ -44,6 +45,7 @@ def breadth_first_search(graph: list, source: int, sink: int, parents: list) ->
4445
parents[ind] = u
4546
return visited[sink]
4647

48+
4749
def ford_fulkerson(graph: list, source: int, sink: int) -> int:
4850
"""
4951
This function returns the maximum flow from source to sink in the given graph.
@@ -92,12 +94,15 @@ def ford_fulkerson(graph: list, source: int, sink: int) -> int:
9294
graph[u][v] -= path_flow
9395
# Ensure reverse edge exists
9496
if graph[v][u] == 0:
95-
graph[v][u] = 0 # Explicitly initialize if needed (though usually already 0)
97+
graph[v][u] = (
98+
0 # Explicitly initialize if needed (though usually already 0)
99+
)
96100
graph[v][u] += path_flow
97101
v = parent[v]
98102

99103
return max_flow
100104

105+
101106
if __name__ == "__main__":
102107
from doctest import testmod
103108

0 commit comments

Comments
 (0)