I am new to python and trying to implement graph data structure in Python. I have written this code, but i am not getting the desired result i want. Code:
class NODE:
def __init__(self):
self.distance=0
self.colournode="White"
adjlist={}
def addno(A,B):
global adjlist
adjlist[A]=B
S=NODE()
R=NODE()
V=NODE()
W=NODE()
T=NODE()
X=NODE()
U=NODE()
Y=NODE()
addno(S,R)
for keys in adjlist:
print keys
I want the code to print {'S':R} on the final line but it is printing this:
<__main__.NODE instance at 0x00000000029E6888>
Can anybody guide me what am i doing wrong? Also what to do if i want to add another function call like addnode(S,E) and printing should be {S:[R,E]}