Graphs mind map

Traverse, color, order, and search weighted graphs.

Core idea: Name the nodes and edges; then ask reachability, order, connectivity, or cheapest path.

Mnemonic: Model → mark → traverse · Cost: O(V + E) traversal

Reach: BFS layers

Signal: Edges are unweighted and the nearest state or fewest moves wins.

Move: Mark on enqueue, process one distance layer at a time, and stop at the first target.

Examples: Word Ladder, Shortest Grid Path, Open the Lock

Explore: DFS structure

Signal: You need components, cycles, coloring, or exhaustive reachability.

Move: Mark each node once; track parent, recursion state, or color when the property needs it.

Examples: Number of Islands, Clone Graph, Bipartite Graph

Organize: Dependencies & connectivity

Signal: Edges mean prerequisite order or undirected membership.

Move: Use indegrees for a topological order; union roots for evolving components.

Examples: Course Schedule, Alien Dictionary, Redundant Connection

Weigh: Cheapest frontier

Signal: Edges carry cost and the answer is a minimum route or spanning connection.

Move: Pop the cheapest unsettled frontier; relax neighbors, or join the cheapest safe component edge.

Examples: Network Delay, Cheapest Flights, Minimum Spanning Tree

Every mind map