Graphs
Data structures with nodes (vertices) and edges connecting pairs of nodes, enabling representation of arbitrary relationships. Graphs generalize trees (acyclic connected graphs) to support cycles and complex connectivity. Directed graphs have edges with direction (A→B), while undirected graphs have bidirectional edges. Weighted edges represent costs or distances between nodes.
Real World
Google Maps models road networks as a weighted graph — junctions are vertices, roads are edges, and distances or travel times are the edge weights used to find shortest routes.
Exam Focus
When asked to represent a graph, state whether you chose adjacency list or matrix and justify with graph density — sparse favours lists.
How well did you know this?