-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadjacency.py
43 lines (37 loc) · 1006 Bytes
/
adjacency.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
# vim: set expandtab:ts=8:sw=4:softtabstop=4:smarttab
#!/usr/bin/env python
from node import Node
from nodeandlabel import NodeAndLabel
class Adjacency:
"""
Represent an adjacency object
"""
def __init__(self, node, *args):
"""
; node,listof(nodeandlabel) -> Adjacency
"""
self.node = node
self.successors = args[0]
def __str__(self):
"""
; -> String
"""
successors = ''
for successor in self.successors:
successors += "%s" % str(successor)
return "%s successor ( %s )" % (self.node, successors)
def __repr__(self):
"""
; -> String
"""
return str(self)
def __name__(self):
"""
; -> String
"""
return "Adjancency"
def __eq__(self, otherAdjacency):
if self.node == otherAdjacency.node and self.successors == otherAdjacency.successors:
return True
else:
return False