← Data Structures & Algorithms learning pathData Structures & Algorithms · Module 9 of 10
Graphs
Model networks and relationships.
📖 Key ideas
- A graph has vertices (nodes) and edges.
- Directed or undirected; weighted or unweighted.
- Represent with adjacency lists (usually) or matrices.
- BFS finds shortest paths in unweighted graphs; DFS explores deeply.
- 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