Depth and breadth-first traversal of C++ adjacency matrix