$30 off During Our Annual Pro Sale. View Details »

Topological sort DFS

Tiffany
November 16, 2022

Topological sort DFS

Tiffany

November 16, 2022
Tweet

More Decks by Tiffany

Other Decks in Science

Transcript

  1. Modified DFS for Topological Sort 21 / 71

  2. Modified DFS for Topological Sort 22 / 71

  3. Modified DFS for Topological Sort 23 / 71

  4. Modified DFS for Topological Sort 24 / 71

  5. Modified DFS for Topological Sort 25 / 71

  6. Modified DFS for Topological Sort 27 / 71

  7. Modified DFS for Topological Sort 28 / 71

  8. Modified DFS for Topological Sort 29 / 71

  9. Modified DFS for Topological Sort 30 / 71

  10. Modified DFS for Topological Sort 31 / 71

  11. Modified DFS for Topological Sort 32 / 71

  12. Modified DFS for Topological Sort 33 / 71

  13. Modified DFS for Topological Sort 34 / 71

  14. Modified DFS for Topological Sort 35 / 71

  15. Modified DFS for Topological Sort 36 / 71

  16. Modified DFS for Topological Sort 37 / 71

  17. Modified DFS for Topological Sort Visited is an empty set

    For each startvertex in verticies: if startvertex in visited continue Push (visit,startvertex) Repeat until stack is empty (action,curr) = pop from stack if action==visit if curr is not in visited add curr to visited Push (finish,curr) for each v adjacent to curr push (visit,v) else Put curr on front of todolist Stack is empty, so outer loop goes to next vertex If we pick Belt (already visited), we just go to the next vertex 38 / 71