Floyd algorithm for calculating multi-source Shortest Path-----

Source: Internet
Author: User

title Link: Https://vjudge.net/contest/146629#problem/L

Title Description: There are n planets, starting at the first planet, seeking to travel all the planet's arrival time and minimum value

Problem Solving Process:

The time required for the first planet to reach the J Planet is T[i][j]

Processing the Floyd algorithm will give the minimum time required for Planet I to reach the J Planet:

     for 1; K <= N; k++)        for1; I <= N; i++)            for1; J <= N; J + +)                = min (T[i][k] + t[k][j], t[i][j]);

Then use DFS to search each planet.

Pruning:

① Current time + time required from the planet to all non-arrival planets < All time limits for the planet not arriving

② (important) current arrival time and + (n -reach planet number) * Current arrival time < known minimum result

Why does the Floyd algorithm put K on the outermost layer? ------Know https://www.zhihu.com/question/30955032

Floyd algorithm for calculating multi-source Shortest path-----

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.