def attack_ordered(ugraphs):
    '''
    attack the ugraph with the ordered nodes
    '''
    result = []
    for ugraph in ugraphs:
        nodes_ordered = targeted_order(ugraph)
        resilience = compute_resilience(ugraph, nodes_ordered)
        result.append(resilience)
    data_file = open('data_resilience_ordered.p', 'wb')
    pickle.dump(result, data_file)
    data_file.close()
    return 'data_resilience_ordered.p'
def attack_ordered(ugraphs):
    '''
    attack the ugraph with the ordered nodes
    '''
    result = []
    for ugraph in ugraphs:
        nodes_ordered = targeted_order(ugraph)
        resilience = compute_resilience(ugraph, nodes_ordered)
        result.append(resilience)
    data_file = open('data_resilience_ordered.p', 'wb')
    pickle.dump(result, data_file)
    data_file.close()
    return 'data_resilience_ordered.p'
def attack(ugraphs):
    '''
    simulate an attack to the given ugraph
    shuffle the nodes, and remove then one by one
    return the cc_size of the ugraph after removed the nodes.
    save the lists into a file.
    '''
    result = []
    for ugraph in ugraphs:
        nodes_random = random_order(ugraph)
        resilience = compute_resilience(ugraph, nodes_random)
        result.append(resilience)
    data_file = open('data_resilience.p', 'wb')
    pickle.dump(result, data_file)
    data_file.close()
    return 'data_resilience.p'
예제 #4
0
def attack(ugraphs):
    '''
    simulate an attack to the given ugraph
    shuffle the nodes, and remove then one by one
    return the cc_size of the ugraph after removed the nodes.
    save the lists into a file.
    '''
    result = []
    for ugraph in ugraphs:
        nodes_random = random_order(ugraph)
        resilience = compute_resilience(ugraph, nodes_random)
        result.append(resilience)
    data_file = open('data_resilience.p', 'wb')
    pickle.dump(result, data_file)
    data_file.close()
    return 'data_resilience.p'