Percolation — Clusters & Critical Threshold (2D)

This 2D companion runs the identical site-percolation algorithm as the 3D version — a random N×N grid unioned into clusters with path-compressed, rank-balanced Union-Find and a virtual top/bottom node pair that detects a spanning cluster — but renders it as a flat, readable Canvas 2D grid instead of a WebGL texture. Drag the p slider through pc ≈ 0.593 to watch isolated clusters snap together into one giant spanning cluster (highlighted in red), track the order parameter P∞ and cluster count live, and read the cluster-size histogram flatten toward a power law right at criticality.