diff --git a/Graph/graph/graph_1.py b/Graph/graph/graph_1.py index 4d7fc83fa94dca0654af42efd8ba7461369e6a36..c44a08b560c88b14000dd0c7981045c0d3a70496 100644 --- a/Graph/graph/graph_1.py +++ b/Graph/graph/graph_1.py @@ -1,6 +1,6 @@ import itertools -from typing import Iterator, Optional +from typing import Iterator, Set, Optional class NDGraph: @@ -14,7 +14,7 @@ class NDGraph: """ def __init__(self): - self.nodes = set() + self.nodes: Set['Node'] = set() def add_node(self, node: 'Node') -> None: self.nodes.add(node) @@ -29,7 +29,7 @@ class Node: def __init__(self): self.id: int = next(self._id) - self.neighbors = set() + self.neighbors: Set['Node'] = set() def __hash__(self): # to be usable in set an object must be hashable diff --git a/Graph/graph/graph_2.py b/Graph/graph/graph_2.py index a06b03b687db134f40b31fe1aa79c4b024c267c8..5f5acb0ea05edf2648d015a9ff01159dffd908c8 100644 --- a/Graph/graph/graph_2.py +++ b/Graph/graph/graph_2.py @@ -1,6 +1,6 @@ import itertools -from typing import Iterator, Set, Sequence +from typing import Iterator, Dict, Set, Sequence class NDGraph: @@ -14,8 +14,8 @@ class NDGraph: """ def __init__(self, nodes): - self.nodes = {n for n in nodes} - self.vertices = {n: set() for n in self.nodes} + self.nodes: Set['Node'] = {n for n in nodes} + self.vertices: Dict['Node': Set['Node']] = {n: set() for n in self.nodes} def add_node(self, node: 'Node') -> None: