There are n cities, city 0 is the hub. Every ordered pair of distinct cities has demand of d passengers per day (unit: passengers per ordered pair per day). An aircraft has s seats (unit: seats per flight). A route joins two cities; a segment is one passenger flying one route in one direction.
The first is the number of ways to choose two cities from n. The second is one spoke from each non-hub city to the hub. For n = 50 that is 1,225 routes against 49. The script checks both counts by listing the routes for n = 2 to 8.
With direct routes every passenger flies one segment, so the n(n−1) ordered pairs give n(n−1) segments per unit of d. In the hub network a passenger to or from the hub flies one segment and every other passenger flies two. There are 2(n−1) ordered pairs that involve the hub and (n−1)(n−2) that do not, so the total is 2(n−1) + 2(n−1)(n−2) = 2(n−1)2.
For n = 50: 4,802 segments against 2,450, a ratio of 1.96. The hub nearly doubles the flying passengers do. The script checks both totals by brute force for n = 2 to 8.
A direct route carries d passengers per direction per day. A spoke carries every passenger from its city to the other n−1 cities, so (n−1)d per direction per day: 49d for n = 50. This concentration is the point of the hub. It is what fills the aircraft.
Assume each route in each direction needs at least one flight a day, and flights are added in whole aircraft. Then direct needs n(n−1)·⌈d/s⌉ flights a day and the hub needs 2(n−1)·⌈(n−1)d/s⌉. Take n = 50 and s = 150.
| d (passengers per pair per day) | direct flights/day | hub flights/day | fewer flights |
|---|---|---|---|
| 4 | 2,450 (average load 2.7%) | 196 (average load 65.3%) | hub |
| 73 | 2,450 | 2,352 | hub |
| 74 to 76 | 2,450 | 2,450 | tie |
| 77 | 2,450 | 2,548 | direct |
At low demand the hub needs about one-twelfth of the flights. By d = 77 each direct route is busy enough on its own, and the hub's extra flying costs more than it saves.
python3 book15/ch01-verify.py uses only the standard library, prints every number on this page and exits non-zero on any failure. The Lean file for these counts is not written.