首页 > 其他 > 详细

Solve Longest Path Problem in linear time

时间:2014-04-12 09:04:54      阅读:523      评论:0      收藏:0      [点我收藏+]

We know that the longest path problem for general case belongs to the NP-hard category, so there is no known polynomial time solution for it. However, for a special case which is directed acyclic graph, we can solve this problem in linear time.

First, take a look at an algorithm that sloves the shortest path problem for DAG in linear time, which makes use of Topological sort.

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

The only modificaiton to negate the weight of all edges before running this algorithm in order for it to compute a longest path. This algorithm runs in O(V + E) time, its limitation is that it does not allow cycles in the graph.

 

Solve Longest Path Problem in linear time,布布扣,bubuko.com

Solve Longest Path Problem in linear time

原文:http://www.cnblogs.com/Antech/p/3659943.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!