-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.py
More file actions
42 lines (42 loc) · 961 Bytes
/
Graph.py
File metadata and controls
42 lines (42 loc) · 961 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
32
33
34
35
36
37
38
39
40
41
42
#author: Dino Rossegger
from collections import deque
class Vertex(object):
def __init__(self, name, pre, new, father=None,old=[],next=[],succ=[],oldSym=[]):
self.name=name
self.succ=deque(succ)
self.pre=deque(pre)
self.new=deque(new)
self.oldSym=deque(oldSym)
if father==None:
self.father=name
else:
self.father=father
self.old=deque(old)
self.next=deque(next)
def __str__(self):
string=":"
for i in self.pre:
string+=str(i.name)+" "
string +=":"
for i in self.succ:
string+=str(i.name) +" "
string+=":"
for i in self.old:
string+=str(i)+","
string+=":"
for i in self.oldSym:
string+=str(i)+","
return str(self.name)+string
def ce(self):
return self.name
def __eq__(self,other):
return self.name == other.name
def addPre(self,v):
self.pre.append(v)
def addOld(self,o):
self.old.append(o)
def addSucc(self,v):
self.succ.append(v)
class Init(Vertex):
def __init__(self):
self.name="init"