code: def ford_fulkerson(graph, capacity, s, t):
      
      add_reverse_arcs(graph, capacity)
      n = len(graph)
      flow = [[0] * n for _ in range(n)]
      INF = float('inf')
      while _augment(graph, capacity, flow, INF, s, t, [False] * n) > 0:
          pass                         # work already done in _augment
      return (flow, sum(flow[s]))
docs: Maximum flow by Ford-Fulkerson
  
      :param graph: directed graph in listlist or listdict format
      :param capacity: in matrix format or same listdict graph
      :param int s: source vertex
      :param int t: target vertex
  
      :returns: flow matrix, flow value
      :complexity: `O(|V|*|E|*max_capacity)`