import random
from goody         import irange
from priorityqueue import PriorityQueue
from performance   import Performance


def setup(N):
    global pq
    pq = PriorityQueue([random.randrange(0, N) for i in range(0, N)])
        
def code(N):
    global pq
    for i in range(N):
        pq.remove()
 
for i in irange(0, 8):
    N = 10000*2**i
    P = Performance(lambda: code(10000), lambda: setup(N), 8, title = "\nPriority Queue of size " + str(N))
    P.evaluate()
    P.analyze()
Beispiel #2
0
from performance import Performance
from goody import irange
from graph_goody import random_graph,spanning_tree
from graph import Graph

# Put script below to generate data for Problem #1
# In case you fail, the data appears in sample8.pdf in the helper folder
global nodes
global graph
if __name__ == '__main__':
    nodes = 1000
    while nodes <= 128000:
        graph = random_graph(nodes,lambda n : 10*n)
        perf = Performance(lambda: spanning_tree(graph),setup=lambda:None,times_to_measure=5,title='Spanning Tree Timings for '+str(nodes)+' nodes')
        perf.evaluate()
        perf.analyze()
        nodes *= 2
from performance import Performance
from goody import irange
from graph_goody import random, spanning_tree

# Put script here to generate data for Problem #1
g = None

def create_random(n):
    global g
    g = random(n, lambda n : 10*n) 
    
for i in irange(0,7) :
    n = 1000 * 2**i
    p = Performance(lambda : spanning_tree(g), lambda : create_random(n),5,'Spanning Tree of size {}'.format(n))
    p.evaluate()
    p.analyze()
    print()
Beispiel #4
0
def random_graph(nodes: int, edges: int) -> {str: {str}}:
    g = {str(n): set() for n in range(nodes)}

    for i in range(int(edges)):
        n1 = str(randrange(nodes))
        n2 = str(randrange(nodes))
        if n1 != n2 and n1 in g and n2 not in g[n1]:
            g[n1].add(n2)
            g[n2].add(n1)
    return g


# Put code here to generate data for Quiz 8 problem #1
def create_random():
    global grph
    grph = random_graph(nodes, nodes * 5)


nodes = 100
while nodes <= 12800:
    create_random()
    performance = Performance(code=lambda: find_influencers(graph=grph),
                              setup=lambda: create_random(),
                              times_to_measure=5,
                              title="find_influencers of size " + str(nodes))
    for i in irange(5):
        performance.evaluate()
    performance.analyze()
    nodes = nodes * 2
    print()
Beispiel #5
0
import random
from goody import irange
from performance import Performance
from priorityqueue import PriorityQueue

def setup(size):
    global pq
    alist = [i for i in range(size)]
    random.shuffle(alist)
    pq = PriorityQueue(alist)
    
def code(removes):
    global pq
    for i in range(removes):
        pq.remove()
        
for i in irange(0,8):
    size = 10000 * 2**i
    p = Performance(lambda : code(10000), lambda:setup(size),5,'\n\nPriority Queue of size ' + str(size))
    p.evaluate()
    p.analyze()
Beispiel #6
0
from performance import Performance
from goody import irange
from graph_goody import random, spanning_tree

# Put script here to generate data for Problem #1
def create_random():
    global dog
    dog = random(x*1000, lambda n : 10*n)



if __name__ == '__main__':
    x=1
    while x<129:
        y = Performance(lambda:spanning_tree(dog), lambda:create_random(), title = "Spanning Tree of Size " + str(x*1000))
        y.evaluate()
        y.analyze()
        print()
        x = 2*x
Beispiel #7
0
from graph_goody import random_graph, spanning_tree
from graph import Graph


#Submitter edwardc6(Chen,Edward)
# Put script here to generate data for Problem #1
# In case you fail, the data appears in sample8.pdf in the helper folder
# random(100,lambda n : 10*n)
def create_random(n):
    global rand_graph
    rand_graph = random_graph(n, lambda n: 10 * n)


def span_time(n):
    global rand_graph
    spanning_tree(rand_graph)


z = 500
while True:
    n = z * 2
    if (n == 256000):
        break
    zoon = 'Spanning Tree of size {}'.format(str(n))
    jk = Performance(lambda: span_time(rand_graph), lambda: create_random(n),
                     5, zoon)
    jk.evaluate()
    jk.analyze()
    print()
    z = n
Beispiel #8
0
from performance import Performance
from goody import irange
from graph_goody import random_graph, spanning_tree

# Put script below to generate data for Problem #1
# In case you fail, the data appears in sample8.pdf in the helper folder


def create_random(n, callable):
    return random_graph(n, callable)


n = 1000
while n < 128001:  #Until n reaches 128000
    graph = create_random(n, lambda n: 10 * n)

    p = Performance(lambda: spanning_tree(graph), lambda: None, 5,
                    f'Testing spanning_tree using {n} nodes')
    p.evaluate(5)
    p.analyze()

    n = n * 2  #Double n