During my internship under the guidance of Professor Rupesh Nasre from the Indian Institute of Technology, Madras, I had the opportunity to work on several graph algorithms. This experience enhanced my understanding of algorithmic theory and allowed me to translate concepts to Python concepts. I also did a time-complexity analysis of algorithms, helping me understand their efficiency and scalability.
Most datasets were sourced from Stanford-SNAP, a collection of large datasets, and the time
module was used to measure the time taken for the algorithms to run.
Gale-Shapley Algorithm
Gale-Shapley Algorithm, also known as the Stable Matching Algorithm, is used to find a match between two sets without violating the stability criteria.
Despite being quadratic, it is fairly efficient for medium-sized sets.
Dijkstra's Algorithm
Dijkstra's Algorithm is used for finding the shortest path between two nodes in a graph. It is widely used in network routing and pathfinding. I implemented the algorithm in Python, using a greedy approach to iteratively explore the node with the least distance.
Nodes | Edges | Time (seconds) |
---|---|---|
3 783 | 24 186 | 1,73237 |
5 881 | 35 592 | 1,58963 |
7 115 | 103 689 | 1,33088 |
55 863 | 858 490 | 44,15523 |
75 879 | 508 837 | 216,67614 |
81 306 | 1 768 149 | 190,54480 |
107 614 | 13 673 453 | 207,79644 |
325 729 | 1 497 134 | 1 138,22747 |
685 230 | 7 600 595 | est. 68 400 |
1 791 489 | 28 511 807 | est. 561 600 |
Max-Flow Computation
The Ford-Fulkerson algorithm computes the maximum flow in a flow network by iteratively finding augmenting paths from the source node to the sink node and updating the residual capacities. This is done until no more augmenting paths are found (and the flow is maximised).
I implemented the algorithm using a Breadth First Search approach to find the shortest augmenting path.
Nodes | Edges | Time (seconds) |
---|---|---|
141 | 160 | 0,00009274482727 |
10 680 | 24 316 | 0,00515127182 |
1 226 | 2 615 | 0,8591217995 |
3 783 | 24 186 | 3,224216223 |
23 370 | 33 101 | 3,954843283 |
14 274 | 20 573 | 8,447390079 |
7 115 | 103 689 | 10,03473 |
5 881 | 35 592 | 107,632529 |
24 818 | 506 550 | > 2 hours |
55 863 | 858 490 | > 2 hours |
38 741 | 58 595 | > 2 hours |
My implementation had a time complexity of O(f * E), where f is the maximum flow and E is the number of edges in the graph.