NETWORK FLOWS Shruti Aggrawal Preeti Palkar Requirements 1

  • Slides: 14
Download presentation
NETWORK FLOWS Shruti Aggrawal Preeti Palkar

NETWORK FLOWS Shruti Aggrawal Preeti Palkar

Requirements 1. Implement the Ford-Fulkerson algorithm for computing network flow in bipartite graphs. 2.

Requirements 1. Implement the Ford-Fulkerson algorithm for computing network flow in bipartite graphs. 2. For demo purposes design a GUI in which any bipartite graph of up to 20 nodes can be specified. 3. Animation, which shows each major iteration of the algorithm. 4. Run experiments that measure the performance of the algorithm over large inputs.

Computing Network Flow in Bipartite Graphs • • • Algorithm: Ford Fulkerson Language :

Computing Network Flow in Bipartite Graphs • • • Algorithm: Ford Fulkerson Language : JAVA Bipartite Graphs: – Directed Edges – Flow on each edge = 1. • Input: – Number of nodes on left side – Number of nodes on right side • Algorithm adds source and sink

Path Finding • Find a path from source to sink • Depth First Search

Path Finding • Find a path from source to sink • Depth First Search Algorithm • After finding a path – Increment flow by 1 – Reverse the direction of the edges • Continue till no path more paths can be found – Algorithm terminates

WORKING • In GUI, enter Left nodes and Right nodes and click “Run Algo”

WORKING • In GUI, enter Left nodes and Right nodes and click “Run Algo” • On click of button, a function is called to add nodes and edges of the graph. • Edges between left nodes and right nodes are created randomly. – Create an edge if the probability is > 50% – Call function Math. random(), if result is more than 50% we add edge else not. – Change probability to less than 50% to increase the probability to add number of edges between nodes – Change it to more than 50% to decrease the probability of adding an edge.

Algorithm • A function called traverse() implements the algorithm of path finding and determining

Algorithm • A function called traverse() implements the algorithm of path finding and determining the max flow which can be sent from source to sink. – Implements depth first search – Starts from source and loops through the nodes – For each node it checks if that node is not visited and also not present in the path vector, – If above condition is true it adds it to path and marks the node as visited – It loops through all the out. Edges of a node – Continues till it reaches sink – After finding path, it reverses the edges of this path – Continue till no more path can be found

Design a GUI and show Animation • Enter number of left nodes and right

Design a GUI and show Animation • Enter number of left nodes and right nodes. • Graph is generated for – Left nodes + Right_nodes + Source + Sink • Nodes and Edges that we still need to visit are shown in black • Found path between source and sink is shown in red • Reversed path and visited nodes are shown in green • Once the algorithm terminates it will display the max flow in the top left corner

GUI 13 nodes: 4 left & 7 right nodes

GUI 13 nodes: 4 left & 7 right nodes

Measure performance of the algorithm over large inputs • Array: Store set of left

Measure performance of the algorithm over large inputs • Array: Store set of left and right nodes • Read each pair of input and run algorithm • Observation: – As the number of nodes increases, the time taken to run the algorithm is increases • X-axis represents total number of nodes • Y- axis represents time • {{50, 23}, {100, 48}, {200, 98}, {300, 98}, {40 0, 98}, {200, 398}, {500, 198}, {150, 648, }}

Analysis Output Number of nodes Vs time

Analysis Output Number of nodes Vs time

Analysis w. r. t Number of Edges • • X-axis we have vertices plus

Analysis w. r. t Number of Edges • • X-axis we have vertices plus edges Y -axis we have time 400 vertices & 1000 edges 500 vertices & 900 edges – the time to run algorithm is less for second graph.

Analysis Output : Vertices+Edges Vs time

Analysis Output : Vertices+Edges Vs time

Vertices+Edges Vs time

Vertices+Edges Vs time

Conclusions • Algorithm can be used to find max flow and matching of nodes

Conclusions • Algorithm can be used to find max flow and matching of nodes • GUI and Animation for ease of understanding • Analysis: – As the number of nodes increases, the time taken to run the algorithm is increases – Running time particularly depends on number of edges.