Ejemplo n.º 1
0
        return graph

def random_order(graph):
    list1 = graph.keys()
    random.shuffle(list1)
    return list1

p = 0.5
vertex = 500
    
#print_ER(vertex, p)
#print_Eros(vertex, p)
upa_gr = printUPA(1347, 2)
er_gr = print_Eros(1347, 0.0035)
net_gr = LoadGraph.load_graph(LoadGraph.NETWORK_URL)

upa_attack = random_order(upa_gr)
er_attack = random_order(er_gr)
net_attack = random_order(net_gr)

upa_res = Resiliance.compute_resilience(upa_gr, upa_attack)
er_res = Resiliance.compute_resilience(er_gr, er_attack)
net_res = Resiliance.compute_resilience(net_gr, net_attack)

plt.plot(upa_res, "r", label='UPA (m = 2)')
plt.plot(er_res, "b", label='ER (p = 0.0035)')
plt.plot(net_res, "g", label='NET')
plt.legend(loc='upper right')
plt.ylabel('Largest Connect Component')
plt.xlabel('Number of Nodes Removed')
Ejemplo n.º 2
0
    random.shuffle(list1)
    return list1

p = 0.5
vertex = 500
    
#print_ER(vertex, p)
#print_Eros(vertex, p)
slowT = []
fastT = []
nodes = []

for n in range(10, 1000, 10):
    upa_gr = printUPA(n, 5)
    start = time.clock()
    upa_attack_slow = LoadGraph.targeted_order(upa_gr)
    end = time.clock()
    #startF = time.clock()
    #upa_attack_fast = LoadGraph.fast_targeted_order(upa_gr)
    #endF = time.clock()
    grafTime = end - start
    #grafTimeF = endF - startF
    
    slowT.append(grafTime)
    #fastT.append(grafTimeF)
    
    nodes.append(n)

for n in range(10, 1000, 10):
    upa_gr = printUPA(n, 5)
    #start = time.clock()
Ejemplo n.º 3
0

def random_order(graph):
    list1 = graph.keys()
    random.shuffle(list1)
    return list1


p = 0.5
vertex = 500

# print_ER(vertex, p)
# print_Eros(vertex, p)
upa_gr = printUPA(1347, 2)
er_gr = print_Eros(1347, 0.0035)
net_gr = LoadGraph.load_graph(LoadGraph.NETWORK_URL)

upa_attack = LoadGraph.targeted_order(upa_gr)
er_attack = LoadGraph.targeted_order(er_gr)
net_attack = LoadGraph.targeted_order(net_gr)
# print "upa_attack = ", upa_attack

upa_res = Resiliance.compute_resilience(upa_gr, upa_attack)
er_res = Resiliance.compute_resilience(er_gr, er_attack)
net_res = Resiliance.compute_resilience(net_gr, net_attack)
# print "upa_res = ", upa_res
# targeted2
upa_attack2 = LoadGraph.fast_targeted_order(upa_gr)
er_attack2 = LoadGraph.fast_targeted_order(er_gr)
net_attack2 = LoadGraph.fast_targeted_order(net_gr)
print "upa_attack2 = ", upa_attack2