refactoring in class GraphTraversing