Percolation Visualizer
Description
A visualizer for the percolation problem. Uses Weighted Union Find with Path Compression for solving the problem and StdDraw from alg4.jar to draw. Includes real-time flow which updates filled sites after every new site is opened.
NEW: Interactive mode where you can open and fill sites on the grid using your mouse.
Visuals
Note: Real-time percolation is now way faster, the shown gif is from a previous version.
Installation
Yank the entire directory.
External libraries used: Uses alg4.jar which is included in /lib
. Add it to the referenced libraries.
Usage
Console inputs:
- Run
PercolationVisualizer.java
. - Enter
z
in console for normal randomized site opening mode; orx
for interactive mode. - Steps for different modes:
3.1 (Normal Mode) Enter two ints seperated by a whitespace. The first corresponds to size of the grid, the second to number of trials. Open the newly generated window.
3.2 (Interactive Mode) Enter one int for the size of grid and open the newly generated window.
After each trial, the percent of sites open when percolation happens are logged and displayed for a brief moment (default: 1.5s, can be changed). After the end of all trials, the mean percent of open sites, standard deviation, and other data are shown.
In the interactive mode, keep the sample size low.
Important: You can change boolean realTimeFlow
to turn real time flow off (on by default).
Author
Ajinkya Talekar | ajinkyatalekar.github.io