Expand description
Percolation theory: site and bond percolation on 2D grids, cluster detection via union-find, spanning cluster identification, and critical threshold estimation.
Structs§
- Percolation
Grid - A 2D percolation grid where each site is either open (true) or closed (false).
- Percolation
Renderer - Render a percolation grid with cluster colors and spanning cluster highlighted.
Functions§
- bond_
percolation - Generate a bond percolation grid.
- find_
clusters - Find all connected clusters of open sites using union-find. Returns a vector of clusters, each cluster being a vector of (x, y) coordinates.
- find_
critical_ p - Estimate the critical percolation probability p_c using binary search.
- percolates
- Check if the grid percolates (there exists a cluster spanning from top to bottom).
- percolation_
curve - Compute the percolation curve: probability of percolation vs p.
- percolation_
probability - Estimate percolation probability at a given p.
- site_
percolation - Generate a site percolation grid: each site is open with probability p.
- spanning_
cluster - Find the spanning cluster (if it exists).