Network Optimization Depth First Search James Orlin 2010 Initialize 4 2 1 1 Unmark all nodes in N; 5 3 8 7 6 9 Mark node 1 and add it to LIST LIST 1 2 Select a node i in LIST 4 2 1 1 Select last node in LIST LIST 5 3 8 7 6 9 1 3 If node i is incident to an admissible arc… 2 2 1 1 4 5 Scan an arc out of node 1. 3 8 7 6 9 If endpoint is unmarked, then mark it and add it to LIST. LIST 1 2 4 Select the last node on LIST 2 2 1 1 5 Select Node 2. LIST 3 1 4 8 7 6 9 2 5 If node i is incident to an admissible arc… 2 2 1 1 4 3 5 Scan arc out of node 2. 3 8 7 6 9 Mark node 4 and add it to LIST. LIST 1 2 4 6 Select 2 2 1 1 4 3 5 8 7 Select node 4 3 LIST 1 2 6 9 4 7 If node i is incident to an admissible arc… 2 2 4 3 1 1 5 Scan arc out of node 4. 3 8 4 7 6 9 Mark 8 and add it to LIST. LIST 1 2 4 8 8 Select 2 2 4 3 1 1 5 8 4 7 Select node 8 3 LIST 1 2 4 6 9 8 9 If node i is not incident to an admissible arc… 2 2 4 3 1 1 5 If there are no unscanned arcs out of node 8, delete it from LIST. LIST 1 3 2 4 8 4 7 6 9 8 10 Select 2 2 4 3 1 1 5 8 4 7 Select Node 4 3 LIST 1 2 4 6 9 8 11 If node i is incident to an admissible arc… 2 2 4 3 1 1 5 Scan arc out of node 4. 3 5 8 4 7 6 9 Mark 5 and add it to LIST. LIST 1 2 4 8 5 12 Select 2 2 4 3 1 1 5 5 8 4 7 Select node 5 3 LIST 1 2 4 6 9 8 5 13 If node i is incident to an admissible arc… 2 2 4 3 1 1 5 Scan arc out of node 5. 3 1 2 4 7 6 6 Mark 6 and add it to LIST. LIST 5 8 5 8 4 9 6 14 Select the last node on LIST 2 2 4 3 1 1 5 5 8 4 7 Select node 6 3 LIST 1 2 4 6 6 8 5 9 6 15 If node i is incident to an admissible arc… 2 2 4 3 1 1 5 Scan arc out of node 6. 5 7 3 6 6 Mark 9 and add it to LIST. LIST 1 2 4 8 5 6 8 4 9 7 9 16 Select the last node on LIST 2 2 4 3 1 1 5 5 8 4 7 Select node 9 3 LIST 1 2 4 6 6 8 5 6 9 7 9 17 If node i is incident to an admissible arc… 2 2 4 3 1 1 5 Scan arc out of node 9. 5 7 8 3 1 2 4 9 7 6 6 Mark 7 and add it to LIST. LIST 8 5 6 8 4 9 7 18 Select the last node on LIST 2 2 4 3 1 1 5 5 8 4 7 8 Select node 7 3 LIST 1 2 4 9 7 6 6 8 5 6 9 7 19 Scan arc (7,4) 2 2 4 3 1 1 5 Scan arc out of node 7 5 7 8 3 1 2 4 8 5 9 7 6 6 If endpoint is marked, then label arc as “scanned”. LIST 6 8 4 9 7 20 Scan arc (7,5) 2 2 4 3 1 1 5 Scan arc out of node 7 5 7 8 3 1 2 4 8 5 9 7 6 6 If endpoint is marked, then label arc as “scanned”. LIST 6 8 4 9 7 21 Scan arc (7,8) 2 2 4 3 1 1 5 Scan arc out of node 7 5 7 8 3 1 2 4 8 5 9 7 6 6 If endpoint is marked, then label arc as “scanned”. LIST 6 8 4 9 7 22 If node i is not incident to an admissible arc… 2 2 4 3 1 1 5 There are no arcs out of 7. Delete 7 from LIST LIST 1 5 7 8 3 2 4 9 7 6 6 8 5 6 8 4 9 7 23 Select node 9 2 2 4 3 1 1 5 Select node 9. LIST 1 5 7 8 3 2 4 9 7 6 6 8 5 6 8 4 9 7 24 Scan (9,4) 2 2 4 3 1 1 5 Scan arc out of node 9. 5 7 8 3 1 2 4 8 5 9 7 6 6 If endpoint is marked, then label arc as “scanned”. LIST 6 8 4 9 7 25 Delete 9 from LIST 2 2 4 3 1 1 5 Node 9 has no incident arcs. Delete it from list. LIST 1 5 7 8 3 2 4 9 7 6 6 8 5 6 8 4 9 7 26 Select node 6 2 2 4 3 1 1 5 Select node 6. LIST 1 5 7 8 3 2 4 9 7 6 6 8 5 6 8 4 9 7 27 Scan arc (6.7) 2 2 4 3 1 1 5 Select arc out of node 6. LIST 1 5 7 8 3 2 4 9 7 6 6 8 5 6 8 4 9 7 28 Select node 6 2 2 4 3 1 1 5 Delete node 6 from LIST LIST 1 5 7 8 3 2 4 9 7 6 6 8 5 6 8 4 9 7 29 Select node 5 2 2 4 3 1 1 5 1 7 8 3 Select Node 5 LIST 5 2 4 9 7 6 6 8 5 6 8 4 9 7 30 Select node 5 2 2 4 3 1 1 5 1 7 8 3 Delete node 5 from LIST LIST 5 2 4 9 7 6 6 8 5 6 8 4 9 7 31 Select node 4 2 2 4 3 1 1 5 5 8 4 7 8 Select node 4 3 LIST 1 2 4 9 7 6 6 8 5 6 9 7 32 Delete node 4 2 2 4 3 1 1 5 Delete node 4 from LIST LIST 1 5 7 8 3 2 4 9 7 6 6 8 5 6 8 4 9 7 33 Select node 2 2 2 4 3 1 1 5 5 8 4 7 8 Select Node 2 3 LIST 1 2 4 9 7 6 6 8 5 6 9 7 34 Scan arc (2,5) 2 2 4 3 1 1 5 Scan arc out of node 2 LIST 1 5 7 8 3 2 4 9 7 6 6 8 5 6 8 4 9 7 35 Delete node 2 2 2 4 3 1 1 5 1 7 8 3 Delete node 2 from LIST LIST 5 2 4 9 7 6 6 8 5 6 8 4 9 7 36 Select node 1 2 2 4 3 1 1 5 5 8 4 7 8 Select node 1 3 LIST 1 2 4 9 7 6 6 8 5 6 9 7 37 Scan arc (1,3) 2 2 4 3 1 1 5 Scan arc out of node 1 LIST 1 5 7 8 3 9 2 3 4 9 7 6 6 8 5 6 8 4 9 7 38 Select node 3 2 2 4 3 1 1 5 5 8 4 7 8 Select node 3 3 9 LIST 1 2 3 4 9 7 6 6 8 5 6 9 7 39 Scan arcs (3,5) and (3,6) 2 2 4 3 1 1 5 Scan arcs out of node 3 LIST 1 5 7 8 3 9 2 3 4 9 7 6 6 8 5 6 8 4 9 7 40 Delete node 3 2 2 4 3 1 1 5 Delete node 3 from LIST LIST 1 5 7 8 3 9 2 3 4 9 7 6 6 8 5 6 8 4 9 7 41 Select node 1 2 2 4 3 1 1 5 5 8 4 7 8 Select node 1 3 9 LIST 1 2 3 4 9 7 6 6 8 5 6 9 7 42 Scan arc (1, 5) 2 2 4 3 1 1 5 Scan arc out of (1,5) LIST 1 5 7 8 3 9 2 3 4 9 7 6 6 8 5 6 8 4 9 7 43 Delete node 1 2 2 4 3 1 1 5 Delete node 1 from LIST LIST 1 5 7 8 3 9 2 3 4 9 7 6 6 8 5 6 8 4 9 7 44 LIST is empty 2 2 4 3 1 1 5 The algorithm ends! LIST 1 5 7 8 3 9 2 3 4 9 7 6 6 8 5 6 8 4 9 7 45 The depth first search tree Note that each induced subtree has consecutively labeled nodes 1 1 22 3 9 4 3 4 8 5 5 6 6 9 7 7 8 46 MITOpenCourseWare http://ocw.mit.edu 15.082J / 6.855J / ESD.78J Network Optimization Fall 2010 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
© Copyright 2026 Paperzz