Skip to content
Snippets Groups Projects
Commit 9d461aee authored by Valtteri Virta's avatar Valtteri Virta
Browse files

improved visualisation

parent 94512d28
No related branches found
No related tags found
No related merge requests found
...@@ -116,6 +116,7 @@ class GraphGUI: ...@@ -116,6 +116,7 @@ class GraphGUI:
self.tree.tag_configure('settled', background='lightgreen') self.tree.tag_configure('settled', background='lightgreen')
self.tree.tag_configure('unreachable', background='lightgray') self.tree.tag_configure('unreachable', background='lightgray')
self.tree.tag_configure('normal', background='white') self.tree.tag_configure('normal', background='white')
self.tree.tag_configure('current', background='red')
self.tree.pack(fill="both", expand=True) self.tree.pack(fill="both", expand=True)
# Track canvas items for recoloring # Track canvas items for recoloring
...@@ -123,6 +124,8 @@ class GraphGUI: ...@@ -123,6 +124,8 @@ class GraphGUI:
self._edge_items: dict[tuple[int,int], int] = {} self._edge_items: dict[tuple[int,int], int] = {}
self.settled_nodes: list[Node] = [] self.settled_nodes: list[Node] = []
# easy to use
self.settled_node_ids: list[int] = []
def _on_weight_mode_change(self) -> None: def _on_weight_mode_change(self) -> None:
"""Show or hide min/max weight entries based on weight mode.""" """Show or hide min/max weight entries based on weight mode."""
...@@ -216,6 +219,7 @@ class GraphGUI: ...@@ -216,6 +219,7 @@ class GraphGUI:
"""Reset styling and initialize the Dijkstra step generator.""" """Reset styling and initialize the Dijkstra step generator."""
# Clear # Clear
self.settled_nodes.clear() self.settled_nodes.clear()
self.settled_node_ids.clear()
if not self.graph: if not self.graph:
messagebox.showwarning("No graph", "Generate a graph first.") messagebox.showwarning("No graph", "Generate a graph first.")
...@@ -275,15 +279,19 @@ class GraphGUI: ...@@ -275,15 +279,19 @@ class GraphGUI:
route = routes[nid] route = routes[nid]
dist_str = str(dist) if dist is not None else "" dist_str = str(dist) if dist is not None else ""
route_str = "".join(map(str, route)) if route else "" route_str = "".join(map(str, route)) if route else ""
if nid == settled_id: if nid == settled_id:
tag = 'current'
elif nid in self.settled_node_ids:
tag = 'settled' tag = 'settled'
elif dist is None: elif dist is None:
tag = 'unreachable' tag = 'unreachable'
else: else:
tag = 'normal' tag = 'normal'
self.tree.insert("", "end",
values=(nid, dist_str, route_str), self.tree.insert("", "end",values=(nid, dist_str, route_str),tags=(tag,))
tags=(tag,))
self.settled_node_ids.append(settled_id)
root = tk.Tk() root = tk.Tk()
app = GraphGUI(root) app = GraphGUI(root)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment