CPSC 203, 2025 W1
November 25, 2025
SSSP: “many one-way routes from home (tree)” vs TSP: “one big round trip through everyone (loop)”
| Aspect | SSSP (Single-Source Shortest Paths) | TSP (Travelling Salesperson) |
|---|---|---|
| Goal | Shortest route from one start to each vertex | One cheapest tour visiting all vertices and returning |
| Shape | Tree of paths from the source | Cycle through all vertices |
| Must visit all? | No – each path can skip most vertices | Yes – must visit every vertex exactly once |
| Overlap | Paths often share edges | Tour is one sequence; no repeated visits |
| Difficulty | Fast algorithms (e.g., Dijkstra) | NP-hard; exact solution is hard for large graphs |
https://medium.com/data-science/around-the-world-in-90-414-kilometers-ce84c03b8552
Steps to assemble our solution:
________________________________________
________________________________________
________________________________________
________________________________________
________________________________________
lambda Do?Goal: Create a new column (latlong) and fill it with coordinates for each errand in the dataframe.
How it works:
df.apply(..., axis=1): Run a function once for each row.
lambda row: ox.geocode(row['errand']): A tiny inline function. Read it as: “Given a row, look up the place name in row['errand'],geocode it, and return the (lat, lon).”
The returned value becomes the entry in the new latlong column.
Why lambda? We only need this function once, so we write it right where it’s used.
We assemble each candidate solution as an arrangement of all of the errands:
Ex: A D B E F C
How do we find the total distance if we do the errands in the suggested order?
There are lots of applications: