def evaluate(n, p, trials):
    count = 0
    for i in range(trials):
        # Generate one random network.
        isOpen = percolationio.random(n, p)
        if (percolationv.percolates(isOpen)):
            count += 1
    return 1.0 * count / trials
Exemple #2
0
def evaluate(n, p, trials):
    count = 0
    for i in range(trials):
        # Generate one random network.
        isOpen = percolationio.random(n, p)
        percolation.flow(isOpen)
        count += max(percolation.depth_l)
    return 1.0 * count / trials
Exemple #3
0
def main():
    n = int(sys.argv[1])
    p = float(sys.argv[2])
    trials = int(sys.argv[3])
    for i in range(trials):
        isOpen = percolationio.random(n, p)
        stddraw.clear()
        stddraw.setPenColor(stddraw.BLACK)
        percolationio.draw(isOpen, False)
        stddraw.setPenColor(stddraw.BLUE)
        full = percolation.flow(isOpen)
        percolationio.draw(full, True)
        stddraw.show(1000.0)
    stddraw.show()
Exemple #4
0
def main():
    # n = int(sys.argv[1])
    # p = float(sys.argv[2])
    # trials = int(sys.argv[3])
    n = 20
    p = .5
    trials = 5
    for i in range(trials):
        isOpen = percolationio.random(n, p)
        stddraw.clear()
        stddraw.setPenColor(stddraw.BLACK)
        stddraw.setPenRadius(0.005)
        percolationio.draw(isOpen, True)
        stddraw.setPenColor(stddraw.BLUE)
        stddraw.setPenRadius(0.05)
        full = percolation.flow(isOpen)
        percolationio.draw(full, True)
        stddraw.show(1000.0)
    #print('over')
    stddraw.show()