def predecessor_traverse(p,s,g):
    """Used by dijkstra's algorithm to traverse a predecessor dictionary"""
    L = []
    v = g
    while v is not None:
        L.append(v)
        v = p.get(v,None)
    #rather than prepending, we appended and now we'll reverse.  This is a more efficient than prepending
    return L[::-1]