Pythonic Example of breadth first and depth first search. Also demonstrating negative edge weights and relaxation. Ultimately builds an imperfect but useful powerpoint presentation.
- The first several programs do not require any libraries.
- Step 6 is the first step that requires a python environment because of two libraries. Before that step:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
- Step-by-step buildup:
- Start with graph construction from the provided input format.
- Visualize simple graph examples to introduce nodes and edges.
- Implement BFS, showing node discovery order and distances.
- Implement DFS, showing discovery and finish times.
- Apply both algorithms to network-like graphs (small-world structures, grid networks).
- Progressive Examples:
- Example 1: Simple undirected graph (3-4 nodes).
- Example 2: Directed graph (5-6 nodes).
- Example 3: Network structure (like a grid or small-world).
- Final Demonstration:
- Input parsing from stdin or file (matching the C assignment format).
- Full BFS and DFS traversal with output formatting:
- BFS shows distances.
- DFS shows finish times.