Graphs represent relationships between entities — social networks, maps, dependency trees, and web page links are all graph problems. A graph consists of vertices (nodes) and edges (connections). Graph Types Directed graphs have one-way edges (like Twitter follows). Undirected graphs have two-way edges (like Facebook friendships). Weighted graphs assign costs to edges (like road distances). Graphs can be stored as an adjacency list (space-efficient for sparse graphs) or an adjacency matrix (fast lookups for dense graphs). Traversal Algorithms BFS (Breadth-First Search) explores level by level using a queue — ideal for finding the shortest path in unweighted graphs. DFS (Depth-First Search) explores as deep as possible using a stack or recursion — ideal for cycle detection, topological…