Minor refactoring
DFS and BFS work with weighted graphs