Download presentation
Presentation is loading. Please wait.
1
15.082 and 6.855J Topological Ordering
Get ahold of a network, and use the same network to illustrate the shortest path problem for communication newtorks, the max flow problem, the minimum cost flow problem, and the multicommodity flow problem. This will be a very efficient way of introducing the four problems. (Perhaps under 10 minutes of class time.)
2
Preliminary to Topological Sorting
LEMMA. If each node has at least one arc going out, then the first inadmissible arc of a depth first search determines a directed cycle. COROLLARY 1. If G has no directed cycle, then there is a node in G with no arcs going. And there is at least one node in G with no arcs coming in. COROLLARY 2. If G has no directed cycle, then one can relabel the nodes so that for each arc (i,j), i < j. 1 4 6 7 3
3
Initialization 6 1 Determine the indegree of each node
LIST is the set of nodes with indegree of 0. “Next” will be the label of nodes in the topological order. 5 2 8 3 7 4 next 1 2 3 4 5 6 7 8 Node Indegree LIST 7
4
Select a node from LIST 6 1 next := next +1 order(i) := next;
update indegrees update LIST Select a node from LIST and delete it. 5 2 8 3 7 7 4 1 1 next 1 2 3 4 5 6 7 8 Node LIST Indegree 2 2 3 2 1 1 1 2 7 5
5
Select a node from LIST 6 1 next := next +1 order(i) := next;
update indegrees update LIST Select a node from LIST and delete it. 2 5 5 2 8 3 7 7 4 1 1 2 next 1 2 3 4 5 6 7 8 Node LIST Indegree 2 2 1 3 2 1 1 1 2 4 5 7 6
6
Select a node from LIST 3 6 6 1 next := next +1 order(i) := next;
update indegrees update LIST Select a node from LIST and delete it. 2 5 5 2 8 3 7 7 4 1 2 1 3 next 1 2 3 4 5 6 7 8 Node LIST Indegree 1 2 2 1 3 1 2 1 1 2 4 5 7 2 6
7
Select a node from LIST 3 6 6 1 next := next +1 order(i) := next;
update indegrees update LIST Select a node from LIST and delete it. 2 5 5 2 2 8 3 4 7 7 4 1 4 3 2 1 next 1 2 3 4 5 6 7 8 Node LIST Indegree 1 2 2 1 3 2 1 1 1 2 4 7 5 6 2 1
8
Select a node from LIST 5 3 6 6 1 1 next := next +1 order(i) := next;
update indegrees update LIST Select a node from LIST and delete it. 2 5 5 2 2 8 3 4 7 7 4 1 3 5 2 4 1 next 1 2 3 4 5 6 7 8 Node LIST Indegree 1 2 1 2 2 3 2 1 1 1 2 1 4 7 5 1 2 6
9
Select a node from LIST 5 3 6 6 1 1 next := next +1 order(i) := next;
update indegrees update LIST Select a node from LIST and delete it. 2 5 5 2 2 8 3 4 7 7 4 4 1 6 6 3 5 4 2 1 next 1 2 3 4 5 6 7 8 Node LIST Indegree 1 2 2 1 3 2 1 1 2 1 1 2 1 2 1 4 6 7 5 8
10
Select a node from LIST 5 3 6 6 1 1 next := next +1 order(i) := next;
update indegrees update LIST Select a node from LIST and delete it. 7 2 5 5 2 2 8 8 3 4 7 7 4 4 1 6 2 7 4 5 3 6 1 next 1 2 3 4 5 6 7 8 Node LIST Indegree 1 2 1 2 2 3 1 1 2 1 1 1 2 8 3
11
Select a node from LIST 5 3 6 6 1 1 next := next +1 order(i) := next;
update indegrees update LIST Select a node from LIST and delete it. 7 8 2 5 5 2 2 8 8 3 3 4 7 7 4 4 1 6 2 5 8 6 7 3 1 4 next List is empty. The algorithm terminates with a topological order of the nodes 1 2 3 4 5 6 7 8 Node LIST Indegree 1 2 2 1 2 1 3 1 2 1 1 2 1 3
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.