Demo entry 6345738



Submitted by anonymous on Feb 06, 2017 at 02:14
Language: Python 3. Code size: 278 Bytes.

def dfs_paths(graph, start, goal, path=None):
    if path is None:
        path = [start]
    if start == goal:
        yield path
    for next in graph[start] - set(path):
        yield from dfs_paths(graph, next, goal, path + [next])

list(dfs_paths(graph, 'C', 'F')) 

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).