title: Make a topological search function with given depth first search function
body: <p>I am making a stack of vertices after a topological sort. I think the code I have written is correct but I do not know how to print out the stack.
  This is my code:</p>
  
  <pre><code>  def toposort (self):
      stack = Stack()
      top = []
      for i in range(0,len(self.Vertices)):
        self.Vertices[i].visited == False
      for i in range(0,len(self.Vertices)):
        if not (self.Vertices[i]).wasVisited():
          self.dffs(self.getIndex(i),stack)
      return stack
  
    def dffs(self, v, stack):
      self.Vertices[v].visited == True
      for i in range(0,len(self.Vertices)):
        if (self.adjMat[v][i] &gt; 0) and (not (self.Vertices[i]).wasVisited()):
          self.dffs(self.getIndex(self.Vertices[i]), stack)
          print (self.Vertices[v])
      stack.push(v)
  </code></pre>
  
  <p>and the output I get is: &lt;<strong>main</strong>.Stack object at 0x104adf1d0>
  I'm sure it is an easy fix but I just don't know how. My graph is a bunch of vertexes and labels with weights.</p>
  
  <pre><code>class Stack (object):
    def __init__ (self):
      self.stack = []
  
    # add an item to the top of the stack
    def push (self, item):
      self.stack.append ( item )
  
    # remove an item from the top of the stack
    def pop (self):
      return self.stack.pop()
  
    # check what item is on top of the stack without removing it
    def peek (self):
      return self.stack[len(self.stack) - 1]
  
    # check if a stack is empty
    def isEmpty (self):
      return (len(self.stack) == 0)
  
    # return the number of elements in the stack
    def size (self):
      return (len(self.stack))
  </code></pre>