예제 #1
0
def eval(n, p, t):
    cnt = 0
    for i in range(t):
        # Generate one random network.
        open = percolation.random(n, p)
        if (percolation.percolates(open)):
            cnt += 1
    return float(cnt) / t
예제 #2
0
def evaluate(n, p, trials):
    count = 0
    for i in range(trials):
        # Generate one random network.
        isOpen = percolationio.random(n, p)
        if (percolation.percolates(isOpen)):
            count += 1
    return count
예제 #3
0
def eval(n, p, t):
    cnt = 0
    for i in range(t):
        # Generate one random network.
        open = percolation.random(n, p)
        if (percolation.percolates(open)):
            cnt += 1
    return float(cnt) / t
예제 #4
0
def evaluate(n, p, trials):
    count = 0
    for i in range(trials):
        # Generate one random network.
        isOpen = percolationio.random(n, p)
        if (percolation.percolates(isOpen)):
            count += 1
    return 1.0 * count / trials
예제 #5
0
def main():
    A=perc.make_sites(0.6,25)
    perc.write_grid('sites.txt',A)
    B=perc.read_grid('sites.txt')
    C=perc.flow(B)
    if perc.percolates(C):
        print('percolates')
    else:
        print('does not percolate')
예제 #6
0
def main():
    site_matrix=perc.make_sites(25,0.45)
    perc.write_grid('sites.txt',site_matrix)
    sites_read=perc.read_grid('sites.txt')
    sites_flow=perc.vertical_flow(sites_read)
    if perc.percolates(sites_flow):
        print('percolates')
    else:
        print('does not percolate')
예제 #7
0
def main():
    A=perc.make_sites(25,0.45)
    perc.write_grid('sites.txt',A)
    infile=open('sites.txt','r')
    B=perc.read_grid(infile)
    C=perc.flow(B)
    if perc.percolates(C):
        print('percolates')
    else:
        print('does not percolate')
예제 #8
0
def main():
    """Test Percolation Vertical."""
    A = perc.make_sites(25, 0.45)
    perc.write_grid('sites.txt', A)
    infile = open('sites.txt', 'r')
    B = perc.read_grid(infile)
    C = perc.flow(B)
    if perc.percolates(C):
        print('percolates')
    else:
        print('does not percolate')
예제 #9
0
def main():
    A = perc.make_sites(25, 0.65)
    perc.write_grid('test.txt', A)
    infile = open('test.txt', 'r')
    B = perc.read_grid(infile)
    C = perc.flow(B)
    if perc.percolates(C):
        print('percolates')
    else:
        print('does not percolate')

    perc.plot(B, C)
예제 #10
0
def main():
    """Test Percolation Vertical."""
    A = perc.make_sites(25, 0.45)
    perc.write_grid('sites.txt', A)
    infile = open('sites.txt', 'r')
    B = perc.read_grid(infile)
    infile.close()
    C = perc.flow(B)
    if perc.percolates(C):
        print('percolates')
    else:
        print('does not percolate')