Thereare V tasks to do. Some task(s) can begin only after a particular task ends,which we will call precedence relation. A graph indicating precedence relationof tasks is given. In this graph, each task is denoted as vertex, and the precedencerelation as directed edge. Note there is no cycle with this graph (cycle refers to a path that starts from one vertex and returns to the same vertex). The graph below is one example of such graph
In this graph, task 1 can start after task 4 ends and task 6can when task 5 and task 7 end; there is no cycle with this graph.
Manager Kim is going to finish a set of tasks having precedencerelation by taking care of one task at a time. If he is going to do this withthe set of tasks illustrated above, the tasks can be handled with the followingorder.
8, 9, 4, 1, 5, 2, 3, 7, 6
And the order below is also possible.
4, 1, 2, 3, 8, 5, 7, 6, 9
But, the order below is not possible.
4, 1, 5, 2, 3, 7, 6, 8, 9
With this order, task 5 is handled earlier that task 8, but inthe precedence relation given in the graph above, task 5 can only begin whentask 8 ends so this order is not possible.