Answer
Using Exercise 60 to construct an algorithm for determining whether a directed graph contains a circuit.
Work Step by Step
--According to Exercise 60, a directed graph contains a circuit if and only if there are any back edges.
--We can detect back edges as follows. Add a marker on each
vertex v to indicate what its status is: not yet seen (the initial situation), seen (i.e., put into T ) but not yet finished (i.e.,visit(v) has not yet terminated), or finished
-(i.e., visit(v) has terminated).A few extra lines in Algorithm 1 will accomplish this bookkeeping.
--then to determine whether a directed graph has a circuit,
- we just have to check when looking at edge uv whether the status of v is “seen.” If that ever happens,
-then we know there is a circuit; if not, then there is no circuit.