4 ms·
Another way to do it is to DFS or BFS a graph while marking nodes "visited" or not. This is exactly how we did it in my algorithm course. Our teacher showed th
by ramchip 18y ago
Another way to do it is to DFS or BFS a graph while marking nodes "visited" or not.
This is exactly how we did it in my algorithm course. Our teacher showed that quite a lot of graph algorithms can be implemented as a simple variation of a generic DFS or BFS, so the advantage of doing it this way is that you can reuse the same base code.