Graph Data Structure And Algorithms

  • Last Updated : 26 Sep, 2023

DSA for Beginners
Learn more about Graph in DSA Self Paced Course
Practice Problems on Graphs

What is Graph Data Structure?

A Graph is a non-linear data structure consisting of vertices and edges. The vertices are sometimes also referred to as nodes and the edges are lines or arcs that connect any two nodes in the graph. More formally a Graph is composed of a set of vertices( V ) and a set of edges( E ). The graph is denoted by G(E, V).

What is Graph in Data Structure & Algorithms

Components of a Graph

  • Vertices: Vertices are the fundamental units of the graph. Sometimes, vertices are also known as vertex or nodes. Every node/vertex can be labeled or unlabelled.
  • Edges: Edges are drawn or used to connect two nodes of the graph. It can be ordered pair of nodes in a directed graph. Edges can connect any two nodes in any possible way. There are no rules. Sometimes, edges are also known as arcs. Every edge can be labeled/unlabelled.

Graphs are used to solve many real-life problems. Graphs are used to represent networks. The networks may include paths in a city or telephone network or circuit network. Graphs are also used in social networks like linkedIn, Facebook. For example, in Facebook, each person is represented with a vertex(or node). Each node is a structure and contains information like person id, name, gender, locale etc.



  1. Introduction to Graphs
  2. Graph and its representations
  3. Types of Graphs with Examples
  4. Basic Properties of a Graph
  5. Applications, Advantages and Disadvantages of Graph
  6. Transpose graph
  7. Difference between graph and tree

BFS and DFS in Graph:

  1. Breadth First Traversal for a Graph
  2. Depth First Traversal for a Graph
  3. Applications of Depth First Search
  4. Applications of Breadth First Traversal
  5. Iterative Depth First Search
  6. BFS for Disconnected Graph
  7. Transitive Closure of a Graph using DFS
  8. Difference between BFS and DFS

Cycles in Graph:

  1. Detect Cycle in a Directed Graph
  2. Detect cycle in an undirected graph
  3. Detect cycle in a direct graph using colors
  4. Detect a negative cycle in a Graph | (Bellman Ford)
  5. Cycles of length n in an undirected and connected graph
  6. Detecting negative cycle using Floyd Warshall
  7. Clone a Directed Acyclic Graph
  8. Union By Rank and Path Compression in Union-Find Algorithm
  9. Introduction to Disjoint Set Data Structure or Union-Find Algorithm

Shortest Path in Graph:

  1. Dijkstra’s shortest path algorithm
  2. Bellman–Ford Algorithm
  3. Floyd Warshall Algorithm
  4. Johnson’s algorithm for All-pairs shortest paths
  5. Shortest Path in Directed Acyclic Graph
  6. Dial’s Algorithm
  7. Multistage Graph (Shortest Path)
  8. Shortest path in an unweighted graph
  9. Karp’s minimum mean (or average) weight cycle algorithm
  10. 0-1 BFS (Shortest Path in a Binary Weight Graph)
  11. Find minimum weight cycle in an undirected graph

Minimum Spanning Tree:

  1. Prim’s Minimum Spanning Tree (MST)
  2. Kruskal’s Minimum Spanning Tree Algorithm
  3. Difference between Prim’s and Kruskal’s algorithm for MST
  4. Applications of Minimum Spanning Tree Problem
  5. Minimum cost to connect all cities
  6. Total number of Spanning Trees in a Graph
  7. Minimum Product Spanning Tree
  8. Reverse Delete Algorithm for Minimum Spanning Tree
  9. Boruvka’s algorithm for Minimum Spanning Tree

Topological Sorting:

  1. Topological Sorting
  2. All topological sorts of a Directed Acyclic Graph
  3. Kahn’s Algorithm for Topological Sorting
  4. Maximum edges that can be added to DAG so that is remains DAG
  5. Longest Path in a Directed Acyclic Graph
  6. Topological Sort of a graph using departure time of vertex


  1. Articulation Points (or Cut Vertices) in a Graph
  2. Biconnected Components
  3. Bridges in a graph
  4. Eulerian path and circuit
  5. Fleury’s Algorithm for printing Eulerian Path or Circuit
  6. Strongly Connected Components
  7. Count all possible walks from a source to a destination with exactly k edges
  8. Euler Circuit in a Directed Graph
  9. Length of shortest chain to reach the target word
  10. Find if an array of strings can be chained to form a circle
  11. Tarjan’s Algorithm to find strongly connected Components
  12. Paths to travel each nodes using each edge (Seven Bridges of Königsberg)
  13. Dynamic Connectivity | Set 1 (Incremental)

Maximum Flow

  1. Max Flow Problem Introduction
  2. Ford-Fulkerson Algorithm for Maximum Flow Problem
  3. Find maximum number of edge disjoint paths between two vertices
  4. Find minimum s-t cut in a flow network
  5. Maximum Bipartite Matching
  6. Channel Assignment Problem
  7. Introduction to Push Relabel Algorithm
  8. Karger’s Algorithm- Set 1- Introduction and Implementation
  9. Dinic’s algorithm for Maximum Flow

Some must do Problems on Graph:

  1. Find length of the largest region in Boolean Matrix
  2. Count number of trees in a forest
  3. A Peterson Graph Problem
  4. Clone an Undirected Graph
  5. Graph Coloring (Introduction and Applications)
  6. Traveling Salesman Problem (TSP) Implementation
  7. Vertex Cover Problem | Set 1 (Introduction and Approximate Algorithm)
  8. K Centers Problem | Set 1 (Greedy Approximate Algorithm)
  9. Erdos Renyl Model (for generating Random Graphs)
  10. Chinese Postman or Route Inspection | Set 1 (introduction)
  11. Hierholzer’s Algorithm for directed graph
  12. Check whether a given graph is Bipartite or not
  13. Snake and Ladder Problem
  14. Boggle (Find all possible words in a board of characters)
  15. Hopcroft Karp Algorithm for Maximum Matching-Introduction
  16. Minimum Time to rot all oranges
  17. Construct a graph from given degrees of all vertices
  18. Determine whether a universal sink exists in a directed graph
  19. Number of sink nodes in a graph
  20. Two Clique Problem (Check if Graph can be divided in two Cliques)

Some Quizzes:

Quick Links :


Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.