## Flow Network

A flow network is a directed graph where each edge has a capacity and a flow. The capacity is the maximum amount of flow that can pass through the edge, while the flow is the actual amount of flow passing through the edge. A flow network is used to model a system where something flows through a network of pipes, such as water flowing through a pipe system.

The maximum flow problem is to find the maximum amount of flow that can be sent from a source node to a sink node in a flow network. The Ford-Fulkerson algorithm is a widely used algorithm for solving the maximum flow problem.

## Ford-Fulkerson Algorithm

The basic idea of the Ford-Fulkerson algorithm is to find an augmenting path from the source node to the sink node, where an augmenting path is a path in the residual graph that has positive residual capacity on each edge. The residual graph is a modified version of the original graph that shows how much flow can still be sent along each edge.

The algorithm works as follows:

- Initialize the flow on each edge to 0.
- While there is an augmenting path from the source node to the sink node:

a. Find an augmenting path using a search algorithm such as depth-first search or breadth-first search.

b. Calculate the amount of flow that can be sent along the augmenting path by finding the minimum residual capacity on the edges.

c. Update the flow on each edge along the augmenting path by adding the calculated flow.

d. Update the residual graph by subtracting the flow from the capacity on each forward edge and adding the flow to the capacity on each backward edge. - Return the maximum flow.

The Ford-Fulkerson algorithm terminates when there is no more augmenting path from the source node to the sink node. It can be shown that the algorithm always terminates and that the maximum flow is the sum of the flows along all the edges leaving the source node.

## Time Complexity

The time complexity of the Ford-Fulkerson algorithm depends on the search algorithm used to find the augmenting path. The worst-case time complexity of the algorithm is O(Ef), where E is the number of edges in the graph and f is the maximum flow. However, in practice, the algorithm can be much faster, especially if a good search algorithm is used.

**In conclusion,** a flow network is a directed graph where each edge has a capacity and a flow. The maximum flow problem is to find the maximum amount of flow that can be sent from a source node to a sink node in a flow network. The Ford-Fulkerson algorithm is a widely used algorithm for solving the maximum flow problem. The algorithm works by finding an augmenting path from the source node to the sink node and updating the flow on each edge along the path. The time complexity of the algorithm depends on the search algorithm used to find the augmenting path.

- Q-1.
- What do you understand by time and space complexity? What is asymptotic notation? Why it is important? Discuss using suitable example.
- Q-2.
- What is recurrence? Discuss in detail the master method for solving a recurrence.
- Q-3
- What is a Travelling Salesman problem? Discuss the greedy algorithm for solving the Travelling Salesman Problem.
- Q-4
- What do you understand by height balanced tree? What is a splay tree? Discuss the insertion/deletion operation on splay tree.
- Q-5
- What is Minimum Spanning Tree? Discuss the Steps for finding Minimum Spanning Tree using Kruskal’s Algorithm.
- Q-6
- What is a Graph? Discuss the depth first traversal of a graph and its computational complexity. Also discuss the topological sort using depth first traversal.
- Q-7
- What is a flow network? Explain Ford-Fulkerson Algorithm for Maximum Flow Problem.
- Q-8
- What is bitonic sequence? What is merging network? Explain.