From e64271e144acbfd7af4e0d65f9944a44e66be9f3 Mon Sep 17 00:00:00 2001 From: czgdp1807 Date: Fri, 22 Jan 2021 23:15:22 +0530 Subject: [PATCH] fixed vertices --- pydatastructs/graphs/adjacency_list.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pydatastructs/graphs/adjacency_list.py b/pydatastructs/graphs/adjacency_list.py index 526eb9a96..a06e35533 100644 --- a/pydatastructs/graphs/adjacency_list.py +++ b/pydatastructs/graphs/adjacency_list.py @@ -38,8 +38,9 @@ def neighbors(self, node): return [self.__getattribute__(name) for name in node.adjacent] def add_vertex(self, node): - self.vertices.append(node.name) - self.__setattr__(node.name, node) + if not hasattr(self, node.name): + self.vertices.append(node.name) + self.__setattr__(node.name, node) def remove_vertex(self, name): delattr(self, name)