Let us use X→Y to denote that X has a one-way road leading to Y, and use X⇝Y to denote a path from X to Y. Let
FX:={C:X→C}FX:={C:X←C}
denote the set of cities from (to) which all one-way roads lead to (from) X; note that nX=∣FX∣.
We call a path short if and only if the number of roads in it is ≤2; otherwise it is called a long path. We first prove the following Lemma:
Lemma: Let P be an independent set consisting of paths from X to Y, with ∣P∣=p. Then there exists an independent set P′ consisting of paths from X to Y, satisfying ∣P′∣≥p and containing all short paths from X to Y.
Proof: Let us perform the following operations on P.
1. If X→Y and this path is not in P, then add it to P.
2. Suppose there exists a city C satisfying X→C→Y and this path is not in P. Note that P is independent.
- If P has only one path containing X→C or C→Y, remove that path and add X→C→Y.
- If P contains X→C⇝Y and X⇝C→Y, remove these two paths, and add X→C→Y and X⇝C⇝Y to P′.
It is easy to verify that the resulting P′ is independent, P′≥p, and contains all short paths from X to Y. □
Return to the original problem. Take any two cities X and Y, and without loss of generality assume X→Y. Take any independent set of paths P consisting of paths from X to Y with size NXY. Our goal is to obtain, through operations, an independent set of paths Q consisting of paths from Y to X with size NXY−(nX−nY). In this case, by the maximality of NXY, we have
NYX≥NXY−(nX−nY)and similarlyNXY≥NYX−(nY−nX)
Thus we obtain NXY−NYX=nX−nY, which proves the original problem.
To obtain Q, we first use the Lemma to obtain P′. Note the following facts:
- P′ contains all short paths from X to Y, and the number of these short paths equals ∣FX∩FY∣+1.
- The paths in P′ cannot contain any road that would be used by a short path from B to A.
- All long paths in P′ must be of the form X→C∼D→Y. Moreover, by the previous property:
* C∈FY (otherwise the path would not be independent from X→C→Y);
* D∈FX (otherwise the path would share the road Y→C with Y→C→X);
We construct Q in the following way:
- Add all short paths from Y to X into Q.
- For every X→C∼D→Y in P′, add Y→C∼D→X to Q.
It is easy to verify that Q is independent. Moreover, since there are ∣FX∩FY∣+1 short paths from X to Y, and ∣FX∩FY∣ short paths from Y to X,
∣Q∣=∣P′∣−(∣FX∩FY∣+1)+∣FX∩FY∣≥NXY−{(∣FX∩FY∣+1)−∣FX∩FY∣}
Also note that
nX−nY=∣FX∣−∣FY∣=∣FX∩FY∣+∣{X→Y}∣−∣FX∩FY∣=(∣FX∩FY∣+1)−∣FX∩FY∣.
Combining the two equations above, we have
∣Q′∣≥NXY−(nX−nY),
which completes the proof of the original problem.