Question: Suppose that we perform DFS on this graph by obeying the following rules:

• Start from vertex 1.

• At every vertex, process its out-neighbors in ascending order of id.

• Whenever we need to restart, do it from the white vertex with the smallest
id

Show the resulting DFS forest. Furthermore, for every vertex, indicate its discovery time and finish time. also #/ = discovered and #/# = finished

[![enter image description here](https://i.stack.imgur.com/sXPng.png)](https://i.stack.imgur.com/sXPng.png)

dfs tree as follows:

```
               6
               |
1--2--7--3--4--5--8

```

the question ask me to show the resulting forest, yet I'm only producing one tree, what have i done wrong?

Answer: 
You need an `except` clause to use `else`:

> 
> The `try ... except` statement has an optional `else` clause, which, when
>  present, must **follow** all `except` clauses
>  [*Emphasis mine*]
> 
> 
>
I just saw it from the python document page, so I'm just gonna quote what it says to you:

> 
> The try ... except statement has an optional else clause, which, when present, must follow all except clauses. It is useful for code that must be executed if the try clause does not raise an exception. For example:
> 
> 
> 
> ```
>  for arg in sys.argv[1:]:
>         try:
>             f = open(arg, 'r')
>         except IOError:
>             print('cannot open', arg)
>         else:
>             print(arg, 'has', len(f.readlines()), 'lines')
>             f.close()
> 
> ```
> 
>