This module provides depth-first search (DFS) and breadth-first search (BFS) traversal algorithms for graphs.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ucxinstructor/dsa_package/llms.txt
Use this file to discover all available pages before exploring further.
Functions
dfs
Performs depth-first traversal starting from a given vertex.Graph object with an
adjacents(v) method that returns adjacent verticesStarting vertex label
Set of visited vertices (used internally for recursion)
Traversal order result (used internally for recursion)
If True, prints internal state including current vertex, adjacents, stack, and visited set
Internal recursion stack (debug only)
List of vertices in DFS traversal order
dfs_path
Finds a path from start vertex to end vertex using depth-first search.Graph object with an
adjacents(v) methodStarting vertex label
Ending vertex label
Set of visited vertices (used internally)
Path from start to end as a list of vertices, or None if no path exists
bfs
Performs breadth-first traversal starting from a given vertex.Graph object with an
adjacents(v) methodStarting vertex label
If True, prints internal state including current vertex, adjacents, and queue
List of vertices in BFS traversal order
bfs_path
Finds the shortest path from start vertex to end vertex using breadth-first search.Graph object with an
adjacents(v) methodStarting vertex label
Ending vertex label
Shortest path from start to end as a list of vertices, or None if no path exists