Demo entry 3539909



Submitted by anonymous on Jan 11, 2016 at 09:17
Language: Python. Code size: 646 Bytes.

def bfs_paths_visited(graph, start, goal, level_lines):
    stack = [(start, [start])]
    visited = [start]
    while stack:
        #print "while", len(stack)
        (vertex, path) = stack.pop(0) #remove and return first item
        for next in graph[vertex]:
            if next not in visited:
                #print len(visited),next
                if next[0] == goal[0]:
                    return path + [next]
                    stack.append((next, path + [next]))
    print "stack empty"    

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).