1 / 6

Topological Sort Example

Topological Sort Example. This job consists of 10 tasks with the following precedence rules: Must start with 7, 5, 4 or 9. Task 1 must follow 7. Tasks 3 & 6 must follow both 7 & 5. 8 must follow 6 & 4. 2 must follow 4. 10 must follow 2.

yvon
Download Presentation

Topological Sort Example

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Topological Sort Example This job consists of 10 tasks with the following precedence rules: Must start with 7, 5, 4 or 9. Task 1 must follow 7. Tasks 3 & 6 must follow both 7 & 5. 8 must follow 6 & 4. 2 must follow 4. 10 must follow 2. Make a directed graph and then a list of ordered pairs that represent these relationships.

  2. 9 Tasks shown as a directed graph. 1 7 3 8 5 6 4 10 2 Tasks listed as ordered pairs: 7,1 7,3 7,6 5,3 5,6 6,8 4,8 4,2 2,10

  3. 1 1 10 2 0 8 2 0 3 6 2 0 2 0 1 Predecessor Counts Successors 1 1 2 2 3 3 4 4 5 5 6 6 8 7 7 1 3 6 8 8 9 9 10 10

  4. 4 BAG 5 9 Place all tasks that have zero predecessors in a “bag”. 4 7 BAG 5 9 Step 1. Remove any task from the bag and place in sorted list. Sorted List: 7, Step 2. Update Predecessor and Successor arrays as needed.

  5. 10 8 2 3 6 1 3 6 Predecessor Counts Successors 1 0 1 2 1 2 3 1 3 4 0 4 0 5 5 6 1 6 8 7 -1 7 8 2 8 9 0 9 10 1 10

  6. Step 3. Add to bag any tasks that now have zero predecessors. 4 1 BAG 5 9 Step. 4. Repeat steps 1, 2, and 3 until all predecessor counts are -1. (We are performing a “loop” or repetition.)

More Related