:

  1. While vertices remain unsorted:
    1. Select any unsorted vertex and add to a stack
    2. While stack is not empty:
      1. Inspect top element on stack
      2. If has no unsorted neighbours:
        1. Pop from stack and add to list
      3. Else: add unsorted neighbours of to stack
  2. Return sorted list