Week 3
This week focused on the practical implementation of graph algorithms, specifically Depth-First Search (DFS) and the Traveling Salesman Problem (TSP) using exhaustive search. Applying these concepts through programming has highlighted both the elegance of recursive structures and the significant computational challenges associated with NP-hard problems.
Key Concepts & Implementations
- DFS & Systematic Traversal: Implementing DFS for directed graphs reinforced the importance of using a "mark array" to track visitation sequences. A crucial takeaway was ensuring the algorithm follows a numerical ascending order for adjacent vertices to maintain consistency in the output.
- TSP & Exhaustive Search: Tackling the Traveling Salesman Problem required using permutations of vertices to find the optimal Hamiltonian cycle. While effective for a small number of vertices (under 15), this approach clearly demonstrates how quickly the search space grows as more nodes are added.
- Edge Cases in Directed Graphs: A significant portion of the logic involved handling "no-path" scenarios, where a program must return a cost of -1 if a complete cycle back to the starting vertex is impossible.
Current Reflections & Challenges
What is clear: The use of an implicit stack via recursion makes DFS relatively straightforward to implement. I now feel confident in my ability to represent directed graphs using both adjacency lists (for DFS) and adjacency matrices (for TSP weight tracking).
What is challenging: The Traveling Salesman Problem is where I find the most conceptual friction. While generating permutations works for this assignment's constraint of <= 15 vertices, I am curious about the transition to more efficient heuristic methods. The current "Brute Force" method is easy to grasp but feels incredibly "heavy" to execute.
Questions I'm Pondering:
Scaling: At what exact vertex count does the $O(n!)$ complexity of permutations typically become completely unfeasible for a modern standard CPU?
Disconnected Components: Although the DFS assignment allowed us to assume a connected graph, how would the mark array logic shift if we had to handle multiple disconnected components in a directed graph
Comments
Post a Comment