Graph is a non-linear data structure like tree data structure. A Graph is composed of a set of vertices(V) and a set of edges(E). The vertices are connected with each other through edges.
- The limitation of tree is, it can only represent hierarchical data. For situations where nodes or vertices are randomly connected with each other other, we use Graph.
- Example situations where we use graph data structure are, a social network, a computer network, a network of locations used in GPS and many more examples where different nodes or vertices are connected without any hierarchic or constraint on structure.
The following images show different types of graphs that see when solving graph problems.
Basics
BFS and DFS
- Breadth First Traversal
- Depth First Traversal
- BFS vs DFS
- Rotten Tomatoes
- Islands in a Graph
- Flood Fill
- Check for Bipartite
- Word Ladder
- Snakes and Ladder
- Water Jug problem
- Pacific Atlantic Water Flow
- Shortest Path in Binary Matrix
- Clone a Graph
- Transitive Closure
Cycles
- Cycle in a Directed Graph
- Cycle in an undirected graph
- Cycle in a graph using colors
- Negative cycle in a Graph
- Cycles of length n
- Clone a Directed Acyclic Graph
- Disjoint Set Data Structure
Shortest Path
- Dijkstra’s shortest path
- Bellman–Ford
- Floyd Warshall
- Johnson’s algorithm
- Shortest Path in Directed Acyclic Graph
- Dial’s Algorithm
- Multistage Graph (Shortest Path)
- Shortest path in an unweighted graph
- Minimum mean weight cycle algorithm
- Shortest Path in a Binary Graph
- Minimum weight cycle
- D’Esopo-Pape Algorithm