Skip to main content

Module percolation

Module percolation 

Source
Expand description

Percolation theory: site and bond percolation on 2D grids, cluster detection via union-find, spanning cluster identification, and critical threshold estimation.

Structs§

PercolationGrid
A 2D percolation grid where each site is either open (true) or closed (false).
PercolationRenderer
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).