← 🧬 Algorithms & AI

🔤 Aho–Corasick

Show failure links
Current state: root
Char processed:
Fail hops this step: 0
Matches found: 0
FPS:
Drag — rotate · Scroll — zoom

🔤 Aho–Corasick Algorithm Explained

A 3D trie automaton radiates outward from a root node, its teal "goto" edges spelling out a dictionary of patterns and orange failure-link arcs showing how the algorithm falls back without ever rescanning the input.

🔬 What It Demonstrates

All patterns share one trie built from their common prefixes. Failure links, computed once by breadth-first search, redirect a mismatch to the longest suffix of the current match that is still a valid prefix — so the whole dictionary is matched in a single linear pass over the text.

🎮 How to Use

Edit the pattern dictionary and input text, then build the automaton. Press Play or Step to watch the glowing cursor walk goto edges (green) and failure links (orange) character by character, lighting up gold-ringed states whenever a pattern is matched.

💡 Did You Know?

Aho–Corasick runs in time proportional to the input length plus the number of matches — completely independent of how many patterns are in the dictionary — which is why it still powers many antivirus and intrusion-detection signature scanners today.