MCPcopy Create free account
hub / github.com/MolinDeng/Princeton-algs4 / main

Method main

LabEnv/01Lab/Percolation.java:93–105  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

91 }
92
93 public static void main(String[] args) {
94 int n = StdIn.readInt();
95 Percolation p = new Percolation(n);
96 while (!p.percolates()) {
97 for (int row = 1; row <= n; row++)
98 for (int col = 1; col <= n; col++) {
99 if (!p.isOpen(row, col))
100 if (StdRandom.bernoulli(1.0 / (n * n - p.numberOfOpenSites())))
101 p.open(row, col);
102 }
103 }
104 StdOut.println("Percolation threshold is " + p.numberOfOpenSites() / Math.pow(n, 2));
105 }
106}

Callers

nothing calls this directly

Calls 4

percolatesMethod · 0.95
isOpenMethod · 0.95
numberOfOpenSitesMethod · 0.95
openMethod · 0.95

Tested by

no test coverage detected