From c029ff6faecf36f5313867a6c31db8898e7b6672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bertrand=20N=C3=A9ron?= <bneron@pasteur.fr> Date: Mon, 9 Sep 2019 17:18:43 +0200 Subject: [PATCH] :sparkles: add main to use dikjstra --- Graph/labirynth.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Graph/labirynth.py diff --git a/Graph/labirynth.py b/Graph/labirynth.py new file mode 100644 index 0000000..89a0576 --- /dev/null +++ b/Graph/labirynth.py @@ -0,0 +1,21 @@ +from graph.maze import Maze +from graph.graph_3 import Node, Edge, UnDirectedGraph +from graph.traversing import Dikjstra + + +labyrinthe = Maze(10, 10) +#labyrinthe.fill_random() + +graph = UnDirectedGraph() +max = labyrinthe.nb_rows * labyrinthe.nb_cols + +for row in range(labyrinthe.nb_rows): + for col in range(labyrinthe.nb_cols): + cell = labyrinthe.maze[col][row] + if cell == '.': + graph.add_edge(Node(), Node(), rank=max) + +start = graph.get_node_by_id(0) +target = graph.get_node_by_id(12) +paths = Dikjstra(graph, start, target) +print(paths) \ No newline at end of file -- GitLab