Skip to content
Snippets Groups Projects
Verified Commit 46041f6a authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Allow passing multiple, or no, last locations

parent ebd0912b
Branches master
No related tags found
No related merge requests found
from typing import Iterable, Optional, Sequence, Union
from pydot import graph_from_dot_file
......@@ -40,8 +42,16 @@ class Board:
self.ticket_graphs.setdefault(ticket, {}).setdefault(destination, set()).add(departure)
self.ticket_graphs.setdefault("*", {}).setdefault(destination, set()).add(departure)
def get_possible_nodes(self, last: str, tickets: list[str]) -> list[str]:
possible = set((last,))
def get_possible_nodes(
self, tickets: Sequence[str], last: Optional[Union[Iterable[str], str]] = None
) -> set[str]:
if last is None:
possible = set(self.ticket_graphs.get("*", {}).keys())
elif isinstance(last, str):
possible = set((last,))
else:
possible = set(last)
for ticket in tickets:
new_possible = set()
for node in possible:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment