code: def maximum_flow_bfs(adjacency_matrix):
      """
      Get the maximum flow through a graph using a breadth first search
      """
      # initial setting
      new_array = copy.deepcopy(adjacency_matrix)
      total = 0
  
      while True:
          # setting min to max_value
          min_flow = math.inf
          # save visited nodes
          visited = [0] * len(new_array)
          # save parent nodes
          path = [0] * len(new_array)
  
          # initialize queue for BFS
          bfs = queue.Queue()
  
          # initial setting
          visited[0] = 1
          bfs.put(0)
  
          # BFS to find path
          while bfs.qsize() > 0:
              # pop from queue
              src = bfs.get()
              for k in range(len(new_array)):
                  # checking capacity and visit
                  if new_array[src][k] > 0 and visited[k] == 0:
                      # if not, put into queue and chage to visit and save path
                      visited[k] = 1
                      bfs.put(k)
                      path[k] = src
  
          # if there is no path from src to sink
          if visited[len(new_array) - 1] == 0:
              break
  
          # initial setting
          tmp = len(new_array) - 1
  
          # Get minimum flow
          while tmp != 0:
              # find minimum flow
              if min_flow > new_array[path[tmp]][tmp]:
                  min_flow = new_array[path[tmp]][tmp]
              tmp = path[tmp]
  
          # initial setting
          tmp = len(new_array) - 1
  
          # reduce capacity
          while tmp != 0:
              new_array[path[tmp]][tmp] = (
                  new_array[path[tmp]][tmp] - min_flow
              )
              tmp = path[tmp]
  
          total = total + min_flow
  
      return total
  
label_desc: Use image node_id 1 for calling a global function with example usage: maximum_flow_bfs(adjacency_matrix) and returns: total