Exemple #1
0
def algorithm_upa(nodes_n,nodes_m):
    #counter=0
    graph_V=er.algorithm_er_undirected(nodes_m,1.0)
    upa_object=UPATrial(len(graph_V))
    for node_i in range(nodes_m,nodes_n):
        #in_degree_graph=er.compute_in_degrees(graph_V)
        V_=upa_object.run_trial(nodes_m)
        graph_V.update({node_i:set([])})
        for v in V_:
            graph_V[node_i].add(v)
            #counter+=1
        for node in graph_V[node_i]:
            graph_V[node].add(node_i)
    #print counter
    return graph_V
Exemple #2
0
"""Question 1 Application 2 of Algorthmic Thinking Part 1"""
import random_order
import at_project2 as at
import ugraph_at_app_2 as ug
import UPAalgorithm as upa
import undirected_er as er
import matplotlib.pyplot as plt
import numpy as np
import at1_app2_q3 as to

graph1=ug.loader()
graph2=er.algorithm_er_undirected(1239,0.0020)
graph3=upa.algorithm_upa(1239,3)

attack1=to.fast_targeted_order(graph1)
attack2=to.fast_targeted_order(graph2)
attack3=to.fast_targeted_order(graph3)

res_list1=at.compute_resilience(graph1,attack1)
res_list2=at.compute_resilience(graph2,attack2)
res_list3=at.compute_resilience(graph3,attack3)

#len_list=[len(graph1),len(graph2),len(graph3)]

x_axis1=range(len(res_list1))
x_axis2=range(len(res_list2))
x_axis3=range(len(res_list3))

###########################################################################
#xvals = [1, 2, 3, 4, 5]
#yvals1 = [1, 2, 3, 4, 5]