Graph Theory37 sections · 1633 units
Open in Course

Pattern - Implicit Graphs

Deriving Edges

Sometimes the graph is not given explicitly. You must construct it from the problem constraints. These are implicit graphs. The nodes and edges are defined by rules, not by an adjacency list.

Example: In Verifying an Alien Dictionary problem, you're given a list of words and a custom alphabet order. To verify the sorting, you compare adjacent words character by character. The alphabet order defines implicit edges between characters. If character aa must come before bb, that's an edge aba \to b in the ordering graph.

Another example: State-space graphs where nodes are configurations (like puzzle states) and edges are valid moves. You build the graph on-the-fly during BFS/DFS rather than storing it all upfront. Recognizing implicit graphs is key to applying topological sort in non-obvious situations.