from graph import *
from dfs import *

def build(L):
    # L is a list of pairs;
    # create graph with given edges
    G = Graph()
    for e in L:
        G.addEdge(e[0], e[1])
    return G

stk=[]
def stackMe(v):
    global stk
    stk.append(v)

def run():
    global stk
    G = build([(1,4), (3,4), (6,4), (4,5), (2,5), (4,8), (5,7), (7,9), (8,9)])
    dfs_all(G, ignore, stackMe)
    while len(stk) > 0:
        print stk.pop().getId()

run()
