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

Floyd-Warshall

Chen
November 17, 2022

 Floyd-Warshall

Chen

November 17, 2022
Tweet

More Decks by Chen

Other Decks in Science

Transcript

  1. Floyd-Warshall: Dynamic Programming
    Floyd-Warshall computes all pairs, but let us focus on 5 to 6.
    62 / 71

    View Slide

  2. Floyd-Warshall: Dynamic Programming
    We start by considering only start(5) and dest(6) when k is 0.
    63 / 71

    View Slide

  3. Floyd-Warshall: Dynamic Programming
    Then we also consider node 1 when k is 1.
    64 / 71

    View Slide

  4. Floyd-Warshall: Dynamic Programming
    And node 2 when k is 2.
    65 / 71

    View Slide

  5. Floyd-Warshall: Dynamic Programming
    And node 3 when k is 3.....
    66 / 71

    View Slide

  6. Floyd-Warshall: Dynamic Programming
    And node 4 when k is 4.... And so on.
    Note that I have just been filling in the answers for recursive
    calls
    But we actually need to compute those.
    67 / 71

    View Slide

  7. Floyd-Warshall: Dynamic Programming
    Hmm it looks like some of those recursive calls will recompute
    the same thing...
    68 / 71

    View Slide