Graph Traversal Algorithms for train networks