forked from uoy-cs-embs-design-contest/design-contest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.py
executable file
·43 lines (32 loc) · 951 Bytes
/
graph.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
35
36
37
38
39
40
41
42
43
class Vertex:
taskLoad = 0
def __init__(self, taskLoad):
self.taskLoad = taskLoad
class Graph:
vertices = [] # Map
edges = []
def __init__(self):
self.vertices = []
def addVertex(self, v):
if self.containsVertex(v):
return False
self.vertices[v] = [] # Map Edge:Pair<Vertex>
def containsVertex(self, v):
if v in self.vertices:
return True
return False
def addEdge(self, e, v1, v2, utilisation):
if not self.containsVertex(v1) or not self.containsVertex(v2):
return False
if self.findEdge(v1, v2) == False:
return False
pair = Pair(v1, v2, utilisation)
self.edges[e] = pair
class Pair:
v1 = Vertex
v2 = Vertex
utilisation = 0.0
def __init__(self, v1, v2, utilisation):
self.v1 = v1
self.v2 = v2
self.utilisation = utilisation