[JENKINS-20280] Decide variable overriding order with topological sorting

additional changes to #986 .
* Uses topological sorting (`CyclicGraphDetector`) to decide the order to override variables.
    * The implementation is completely changed, so that the diff may be hard to review....
* Changes the interfaces of the sorting inner class (`OverrideOrderCalculator`)
    * The one I committed in the last request is not flexible to change the implementations (Especially for using Map.Entry).
    * It is also changed from public to package scope, not to affect other classes with changes in future.