##################################### # Code for answering question 4 of the application # Load the network-graph print "==========> Loading the network-graph" network_graph = nagen.load_graph(nagen.NETWORK_URL) # Generate the ER-graph print print "==========> Generating the ER-graph" er_graph = nagen.make_graph_ER(1239, 0.0040) # Generate the UPA-graph print print "==========> Generating the UPA-graph" upa_graph = nagen.make_graph_UPA(1239, 3) # Generate the attack orders for the three networks using fast_targeted_order print print "==========> Generating attack schedules" network_attack = nagen.targeted_order(network_graph) er_attack = nagen.targeted_order(er_graph) upa_attack = nagen.targeted_order(upa_graph) # Attack the computer-network print print "==========> Attacking the computer-network" network_resilience = ca.compute_resilience(network_graph, network_attack) # Attack the ER-network print print "==========> Attacking the ER-network"
##################################### # Code for answering question 3 of the application # Initialize the list for the plot num_nodes = [0] time_targeted_order = [0.0] time_fast_targeted_order = [0.0] # Generate all the point for the plot for nodes in range(10, 1000, 10): # Fill in the nodes num_nodes.append(nodes) # Generate the graph to be used print "=====> Generating graph with", nodes, "nodes." UPA_graph = nagen.make_graph_UPA(nodes, 5) # Measure the time for targeted_order print print "=====> Run targeted_order for", nodes, "nodes." start_time = time.time() attack_list = nagen.targeted_order(UPA_graph) end_time = time.time() time_targeted_order.append(end_time - start_time) # Measure the time for fast_targeted_order print print "=====> Run fast_targeted_order for", nodes, "nodes." start_time = time.time() attack_list = nagen.fast_targeted_order(UPA_graph) end_time = time.time() time_fast_targeted_order.append(end_time - start_time) print