-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_graph.py
More file actions
31 lines (24 loc) · 707 Bytes
/
my_graph.py
File metadata and controls
31 lines (24 loc) · 707 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
29
30
31
# -*- coding: utf-8 -*-
class MyGraph:
def __init__(self, n, c):
self.node = n
self.color = c
self.neighbors = []
def set_neighbor(self, n):
self.neighbors.append(n)
def set_neighbors(self, ns):
for i in range(0, len(ns)):
self.set_neighbor(ns[i])
def who_am_i(self, n, ns):
for i in range(0, len(ns)):
if (n == ns[i].node):
return ns[i]
class MyEdge:
def __init__(self, nf, nt, c):
self.node_from = nf
self.node_to = nt
self.cost = c
class MyPair:
def __init__(self, sd, n):
self.shortest_distance = sd
self.node = n