Include this module in your traversal to use ruby’s built-in TSort utility to sort your vertices according to the direction of the edges that connect them.
Modules: Route, Vertex