• + 7 comments

    It's definitely doable in Python. I peeked at your code and the main culprits slowing things down are checkVisitedStatus and findFirstUnvisited which both iterate over the entire vertex list and are called many times. You don't really need either of them. Just iterate over all the vertices in the graph once, calling DFS on each vertex that hasn't been visited, and skipping over the ones that have. At the end of the loop, you will have visited every vertex.