Mr. Flatley
Projects

Solving the Shanghai metro challenge with graph theory

This post is a placeholder outline — replace each section below with your actual write-up, code, and figures.

The challenge

The "subway challenge" asks: starting from one station, what's the fastest way to visit every station (or every line) on a metro network at least once? Shanghai's metro is one of the largest and most complex systems in the world, which makes it a genuinely hard routing problem rather than a toy example.

Finding open data

Describe where you sourced the network data — station names, coordinates, line connections, and interchange points. Mention any licensing notes and how up to date the data is.

Simplifying the network

Explain how you turned raw geographic data into a clean graph: merging duplicate interchange nodes, deciding how to weight edges (time vs. distance vs. number of stops), and any simplifications you made to keep the problem tractable.

Computing the optimal path

This is a route-inspection / Chinese postman style problem when every edge must be covered, or a variant of the travelling salesman problem when every station must be visited. Explain which formulation you used and why, and which Python libraries handled the graph and optimisation (e.g. NetworkX, GeoPandas, OR-tools).

# example placeholder — replace with your real code
import networkx as nx

G = nx.Graph()
# add_edge(station_a, station_b, weight=travel_time)

Results

Show the final route, the total time/distance, and a map or diagram if you have one. Note any interesting quirks the network threw up.