Hey there so currently working on a tutorial on implementing graphs into python using an adjacency list format. I came across an example whereby in the 'class graph' there was an indented contains function used. As shown below.
def __contains__(self, n):
return n in self.vertDict
vertDict is a dictionary initialised through the class. Could i request an explanation of what this functions purpose is?
def addEdge(self,h,t):
if h not in self.vertDict:
newV = self.addVert(h)
if t not in self.vertDict:
newV = self.addVert(t)
self.vertDict[h].addnewLink(self.vertDict[t])
Two birds one stone, I sort of understand the 'addEdge' function but what are the arguments h and t? Is it creating edges?
Appreciate it! I have been seriously struggling with these implementations :'(