Q&A
Q. Editing PercolationVisualizer and PercolationProbability to rename Percolation to PercolationVertical or whatever method we want to study seems to be a bother. Is there a way to avoid doing so?
A. Yes, this is a key issue to be revisited in CHAPTER 3. In the meantime, you can keep the implementations in separate subdirectories, but that can get confusing. Advanced Java mechanisms (such as the classpath) are also helpful, but they also have their own problems.
Q. That recursive flow() method makes me nervous. How can I better understand what it’s doing?
A. Run it for small examples of your own making, instrumented with instructions to print a function-call trace. After a few runs, you will gain confidence that it always marks as full the sites connected to the start site via a chain of neighboring open sites.
Q. Is there a simple nonrecursive approach to identifying the full sites?
A. There are several methods that perform the same basic computation. We will revisit the problem in SECTION 4.5, where we consider breadth-first search. In the meantime, working on developing a nonrecursive implementation of flow() is certain to be an instructive exercise, if you are interested.
Q. PercolationPlot (PROGRAM 2.4.6) seems to involve a huge amount of computation to produce a simple function graph. Is there some better way?
A. Well, the best would be a simple mathematical formula describing the function, but that has eluded scientists for decades. Until scientists discover such a formula, they must resort to computational experiments like the ones in this section.