From c8db7c99409f8e18cabe4f38bde3b4cb1d9aebe1 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Thu, 16 Jun 2022 20:44:58 +0200 Subject: [PATCH] Add bus network --- network_attack_propagation.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/network_attack_propagation.py b/network_attack_propagation.py index 1135094..41a9fcd 100644 --- a/network_attack_propagation.py +++ b/network_attack_propagation.py @@ -70,6 +70,15 @@ def do_graph_animation(output_file_name: str, in_graph: Graph, frame_count: int) plt.show() +def bus_network(n=30) -> Graph: + network = Graph() + nodes = [Node() for _ in range(n)] + edges = [Edge(nodes[i], nodes[i+1], 1.0) for i in range(n-1)] + + network.add_edges(edges) + return network + + def main(): network = Graph() nodes = [Node(True), Node(), Node(), Node(True), Node()] @@ -85,6 +94,9 @@ def main(): do_graph_animation('test.gif', network, 5) + bus = bus_network() + do_graph_animation('bus.gif', bus, 5) + if __name__ == "__main__": main()