Optimizing paths on networks is crucial for many applications, ranging from subway traffic to Internet communication. Because global path optimization that takes account of all path choices simultaneously is computationally hard, most existing routing algorithms optimize paths individually, thus providing suboptimal solutions. We use the physics of interacting polymers and disordered systems to analyze macroscopic properties of generic path optimization problems and derive a simple, principled, generic, and distributed routing algorithm capable of considering all individual path choices simultaneously. We demonstrate the efficacy of the algorithm by applying it to: (i) random graphs resembling Internet overlay networks, (ii) travel on the London Underground network based on Oyster card data, and (iii) the global airport network. Analytically derived macroscopic properties give rise to insightful new routing phenomena, including phase transitions and scaling laws, that facilitate better understanding of the appropriate operational regimes and their limitations, which are difficult to obtain otherwise. P ath optimization affects many of our daily activities. Although much attention has been dedicated to routing algorithms for Internet applications, such as instant messengers and peer-to-peer systems (1, 2), many other essential routing applications have attracted less attention, ranging from water distribution networks (3) to sensor networks (4), military convoy movements (5), and journey planners (6, 7). In many applications, enormous costs are incurred due to traffic congestion or nonessential and redundant capacity. Due to the computational costs involved, most existing routing algorithms are static and based on selfish decisions, with nonadaptive routing tables indicating the shortest path to destinations regardless of local traffic (8, 9). Dynamic routing protocols do exist, but they are either heuristic, probabilistic, or insensitive to other individual path decisions that dynamically constitute the traffic (10, 11). A more global approach that takes into account all individual path decisions is crucial for efficient use of overstretched infrastructure. For instance, one may suppress congestion by minimizing overlaps with other routes or decrease the number of active nodes by consolidating paths to reduce infrastructure demands or energy consumption. The latter is particularly important in the context of the Internet because it can consume up to 4% of the electricity generated (12). Future applications include individualized routing and optimal resource management of prebooked air and road traffic.The difficulty in deriving a globally optimal algorithm, in contrast to greedy local ones, lies in the simultaneous assignment of multiple interacting paths to minimize a global cost, because the optimal path between any particular source-destination pair depends on all other path choices. Such interaction is highly nonlocal, because paths between different source-destination pairs may partially overlap. Existing a...