-
Notifications
You must be signed in to change notification settings - Fork 0
/
vertex.py
33 lines (29 loc) · 863 Bytes
/
vertex.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
class Vertex():
def __init__(self):
self.minweight = 99000000
self.parent = None
self.childs = []
self.value = None
self.smallest_node = None
self.root = self
def addNode(self, u):
if not self.value:
self.value = set()
self.value.add(u)
if u.weight < self.minweight:
self.minweight = u.weight
self.smallest_node = u
def __lt__(self, other):
return self.minweight < other.minweight
def __repr__(self):
if not self.value:
return "{empty}"
res = "{"
for i in self.value:
res += str(i.id) + " "
return res + "}"
def __str__(self):
res = "{"
for i in self.value:
res += str(i.id) + " "
return res + "}"