```python
def num_connected_components(g): # g is an UndirectedGraph class
# your code here
Find the number of (maximal) strongly connected components in an undirected graph from the results of a DFS. Implement the function num_connected_components that takes in a graph g and returns a number that indicates the number of MScCs in the directed graph.
Example:
Consider the graph below.
It has 3 maximal strongly connected components that have vertices {0, 1, 2, 3, 4}, {5, 6}, and {7}, respectively. Given such a graph, your function must return the number 3.
Hint: Examine the DFS traverse graph function carefully. How do you distinguish different connected components in a graph from the DFS tree?
def num_connected_components(g): # g is an UndirectedGraph class
# your code here
```