Skip to main content
100%

Gist 13007f773bff03dcdb4117a57b9387c1

✓ Published0🌍 Public
Aaarsenault
Last edited Mar 10, 2017
Created on Mar 10, 2017

This example demonstrates a depth-first search algorithm traversing a small graph represented as a Python dictionary, with sets of neighboring nodes as values. It shows how the search visits nodes from a starting point toward a goal, collecting visited nodes into a set and returning the traversal path when the goal is reached. The code uses plain Python data structures and recursion, with no external visualization libraries. The graph’s six nodes (A through F) and their edges are hardcoded, and the algorithm prints the set of visited nodes upon success, while returning `False` if no path exists.

AI-generated description

Similar vizzes