Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dfs and bfs in python

def shortest_path(graph, start, goal):
    try:
        return next(bfs_paths(graph, start, goal))
    except StopIteration:
        return None

shortest_path(graph, 'A', 'F') # ['A', 'C', 'F']
Source by eddmann.com #
 
PREVIOUS NEXT
Tagged: #dfs #bfs #python
ADD COMMENT
Topic
Name
9+8 =