โ 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