-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefinitions.py
34 lines (24 loc) · 861 Bytes
/
definitions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Edge:
def __init__(self, weight: int, destination) -> None:
self.weight = weight
self.destination = destination
def __str__(self) -> str:
return f"{self.weight}---> {self.destination}"
class Vertex:
__total_ammount: int = 0
__unique_value_list: list = []
def __init__(self, value, edges: list[Edge]) -> None:
if Vertex.__total_ammount > 20:
raise Exception("Limite de vértices alcançado")
self.value = value
self.edges = edges
Vertex.__total_ammount += 1
Vertex.__unique_value_list.append(self.value)
def __str__(self) -> str:
return self.value
def get_total_ammount():
return Vertex.__total_ammount
def is_value_free(value):
if value in Vertex.__unique_value_list:
return False
return True