1919]
2020
2121
22- def breadth_first_search (graph : list , source : int , sink : int , parents : list ) -> bool :
22+ def breadth_first_search (
23+ graph : list , source : int , sink : int , parents : list
24+ ) -> bool :
2325 """
2426 This function returns True if there is a node that has not iterated.
2527
@@ -41,7 +43,7 @@ def breadth_first_search(graph: list, source: int, sink: int, parents: list) ->
4143 """
4244 num_nodes = len (graph )
4345 visited = [False ] * num_nodes
44- queue = deque ()
46+ queue : deque [ int ] = deque ()
4547
4648 queue .append (source )
4749 visited [source ] = True
@@ -97,7 +99,7 @@ def ford_fulkerson(graph: list, source: int, sink: int) -> int:
9799 # Augment the flow while there is a path from source to sink
98100 while breadth_first_search (residual_graph , source , sink , parents ):
99101 # Find the minimum residual capacity along the path
100- path_flow = float ( "inf" )
102+ path_flow = 10 ** 9 # Large integer instead of float
101103 current_node = sink
102104
103105 # Find the minimum capacity in the path
@@ -124,4 +126,4 @@ def ford_fulkerson(graph: list, source: int, sink: int) -> int:
124126 from doctest import testmod
125127
126128 testmod ()
127- print (f"{ ford_fulkerson (graph , source = 0 , sink = 5 ) = } " )
129+ print (f"{ ford_fulkerson (graph , source = 0 , sink = 5 ) = } " )
0 commit comments