From 8a9933e4decb3b6a57b47b6409474bd476920c24 Mon Sep 17 00:00:00 2001
From: Hong-Phuc Bui <hong-phuc.bui@htwsaar.de>
Date: Fri, 27 Sep 2024 01:22:49 +0200
Subject: [PATCH] demo show image

---
 stundenplan/src/pygraph/graphdemo.py |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/stundenplan/src/pygraph/graphdemo.py b/stundenplan/src/pygraph/graphdemo.py
index 2a6cf7d..d8669be 100644
--- a/stundenplan/src/pygraph/graphdemo.py
+++ b/stundenplan/src/pygraph/graphdemo.py
@@ -2,6 +2,9 @@
 
 
 class Graph:
+    """
+    represents an undirected and unweighted Graph
+    """
     def __init__(self):
         self._adjacent: dict[int, set] = {}
         self._vertex_attribute: dict[int, dict] = {}
@@ -25,7 +28,7 @@
             u_neighbor.add(v)
         pass
 
-    def add_edges(self, u: int, adjacent:[int]):
+    def add_edges(self, u: int, adjacent: list[int]):
         for v in adjacent:
             self.add_edge(u, v)
         pass
@@ -44,7 +47,7 @@
         """
         if vertex not in self._adjacent:
             raise ValueError(f"Graph does not include vertex {vertex}")
-        old_attributes = self._vertex_attribute.get(vertex)
+        old_attributes = self._vertex_attribute[vertex]
         self._vertex_attribute[vertex] = old_attributes | properties
         return self
         pass
@@ -75,7 +78,7 @@
     def adjacent_of(self, vertex: int):
         if vertex not in self._adjacent:
             raise ValueError(f"Graph does not include vertex {vertex}")
-        return sorted( self._adjacent.get(vertex) )
+        return sorted( self._adjacent[vertex] )
 
     def for_each_edges(self, action: Callable[[int, int], Any]):
         """
@@ -87,21 +90,18 @@
             for end in self.adjacent_of(start):
                 (first, second) = (start, end) if (start >= end) else (end, start)
             if first in visited_edges:
-                visited_adjacent = visited_edges.get(first)
+                #visited_adjacent = visited_edges.get(first)
+                visited_adjacent = visited_edges[first]
                 if second not in visited_adjacent:
                     visited_adjacent.add(second)
                     action(start, end)
             else:
-                adjacent = set()
+                adjacent: set[int] = set()
                 visited_edges[first] = adjacent
                 adjacent.add(second)
                 action(start, end)
 
-    def get_lecture_name(self, vertex: int):
-        pass
 
-    def set_lecture_name(self, vertex: int, name: str):
-        pass
 
     def __repr__(self):
         text = ""

--
Gitblit v1.10.0-SNAPSHOT