-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchPathMenu.py
43 lines (37 loc) · 1.43 KB
/
SearchPathMenu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from Graph import Graph
from Menu import Menu
from TypesInformedSearch import TypesInformedSearch
from Vertex import Vertex
class SearchPathMenu(Menu):
def __init__(self, title: str, options: list[str]):
super().__init__(title, options)
def interact(self, graph: Graph) -> None:
super().interact()
while not super().is_option_exit():
menu = Menu(
"Selecciona el vertice de inicio ",
self.__update_options(graph.get_vertexs()),
)
menu.interact()
while not menu.is_option_exit():
menu2 = Menu(
f"El vértice de incio es '{graph.get_vertex(menu.get_option()-1)}' y el vértice final es: ",
self.__update_options(graph.get_vertexs()),
)
menu2.interact()
if not menu2.is_option_exit():
graph.shortest_path_with_positions(
TypesInformedSearch.get(super().get_option() - 1),
menu.get_option(),
menu2.get_option(),
)
input()
menu.interact()
super().interact()
def __update_options(self, vertexs: list[Vertex]) -> list[str]:
result = []
for i in vertexs:
if i != "Volver":
result.append(i)
result.append("Volver")
return result