← Data Structures & Algorithms learning path
Data Structures & Algorithms · Module 9 of 10

Graphs

Model networks and relationships.

📖 Key ideas

  1. A graph has vertices (nodes) and edges.
  2. Directed or undirected; weighted or unweighted.
  3. Represent with adjacency lists (usually) or matrices.
  4. BFS finds shortest paths in unweighted graphs; DFS explores deeply.
  5. Applications: maps, social networks, dependencies.
💡 Real-life example: A graph is a city map: places are nodes, roads are edges.
VertexNode in a graph
EdgeConnection between vertices
Adjacency listList of neighbours per vertex
BFS/DFSBreadth-first / depth-first search