-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmst_node.py
More file actions
28 lines (21 loc) · 821 Bytes
/
mst_node.py
File metadata and controls
28 lines (21 loc) · 821 Bytes
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
from __future__ import annotations
from hash_table import HashTable
# just a start point, other nodes that it connects to, and the distances between each
class MSTNode():
def __init__(self, label):
self.label = label
self.nodes = HashTable()
def add_node(self, node: MSTNode, distance):
self.nodes.insert(node, distance)
def remove_node(self, node: MSTNode):
return self.nodes.remove_by_key(node)
def __str__(self):
return f"MSTNode({self.label})"
def __repr__(self):
return f"MSTNode({self.label})"
def __getitem__(self, index):
return [x for x in self.nodes][index]
def __eq__(self, other):
if isinstance(other, MSTNode) and other.label == self.label:
return True
return False