Graph C/C++ Programs
Graph algorithms are used to solve various graph-related problems such as shortest path, MSTs, finding cycles, etc. Graph data structures are used to solve various real-world problems and these algorithms provide efficient solutions to different graph operations and functionalities.
In this article, we will discuss how to implement various graph algorithms in C/C++.
Prerequisite: Graph Data Structure
Graph Algorithm Programs in C/C++
The following is the list of C/C++ programs based on the level of difficulty:
Easy
- Depth First Search or DFS for a Graph
- Breadth First Search or BFS for a Graph
- Find Whether there is Path Between two Cells in Matrix
- Shortest Path in a Binary Maze
- Print All Paths from a Given Source to a Destination
- Find if There is a Path Between Two Vertices in a Directed Graph
- Find a Mother Vertex in a Graph
- Transitive Closure of a Graph
- Eulerian Path in Undirected Graph
- Detect Cycle in an Undirected Graph
Medium
- Detect Cycle in a Directed Graph
- Find the Number of Islands Using DFS
- Introduction to Disjoint Set Data Structure or Union-find Algorithm
- Union by Rank and Path Compression in Union-find Algorithm
- How to Find Shortest Paths From Source to All Vertices Using Dijkstra’s Algorithm
- Kruskal’s Minimum Spanning Tree (MST) Algorithm
- Check if a Graph is Strongly Connected | Set 1 (Kosaraju Using DFS)
- Minimum Time Required to Rot All Oranges
- Floyd Warshall Algorithm | DP-16
- Connected Components in an Undirected Graph
Hard
- Check Whether a Given Graph is Bipartite or Not
- Topological Sorting
- Shortest Path in Directed Acyclic Graph
- Transitive Closure of a Graph
- Articulation Points (or Cut Vertices) in a Graph
- Bridges in a Graph
- Biconnected Graph
- Strongly Connected Components
- Hamiltonian Cycle
- Minimum Cost Path with Left, Right, Bottom, and Up Moves Allowed