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.

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的更多相关文章

  1. Why longest path problem doesn't have optimal substructure?

    We all know that the shortest path problem has optimal substructure. The reasoning is like below: Su ...

  2. Finding the Longest Palindromic Substring in Linear Time

    Finding the Longest Palindromic Substring in Linear Time Finding the Longest Palindromic Substring i ...

  3. HDU1086You can Solve a Geometry Problem too(判断线段相交)

    You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/3 ...

  4. hdu 1086 You can Solve a Geometry Problem too

    You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/3 ...

  5. Eclipse 项目红色叹号:Build Path Problem

    Description Resource Path Location TypeA cycle was detected in the build path of project 'shgl-categ ...

  6. DFS+剪枝 HDOJ 5323 Solve this interesting problem

    题目传送门 /* 题意:告诉一个区间[L,R],问根节点的n是多少 DFS+剪枝:父亲节点有四种情况:[l, r + len],[l, r + len - 1],[l - len, r],[l - l ...

  7. hdu5323 Solve this interesting problem(爆搜)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Solve this interesting problem Time Limit ...

  8. (hdu step 7.1.2)You can Solve a Geometry Problem too(乞讨n条线段,相交两者之间的段数)

    称号: You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/ ...

  9. HDU 1086:You can Solve a Geometry Problem too

    pid=1086">You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Mem ...

随机推荐

  1. Media Player框架

    导入MediaPlayer.framework框架. //声明一个媒体播放器 var moviePlayer:MPMoviePlayerController? @IBAction func playM ...

  2. 设置background属性使用selector的时候内置?attr报错的解决方案

    当我们设置background属性的时候可以设置background="@color/black" 也可以设置 background="@drawable/selecto ...

  3. ITopologicalOperator Buffer调用异常的解决方法 .异常来自 HRESULT:0x8004023E

    最近在做一个分析功能时,需要循环调用Buffer来对图形创建缓冲区.在开发测试时没问题,但拿到客户实际使用时,出现异常. 后来把出异常的数据拿来测试,发现在调用Buffer时出错.但做为参数传入的图形 ...

  4. Magento强大的配置系统

    Magento的配置系统就像是Magento的心脏,支撑着Magento的运行.这套配置系统掌管着几乎所有"module/model/class/template/etc".它把整 ...

  5. JQ 如何设置单选按钮问题

    <input type="radio" name="db_12" value="2" checked="checked/&g ...

  6. 腾讯海量数据处理平台TDW

    TDW是腾讯海量数据处理平台中最核心的模块,它有以下几个作用: 提供海量的离线计算和存储服务.TDW是腾讯内部规模最大的离线数据处理平台,公司内大多数业务的产品报表.运营分析.数据挖掘等的存储和计算都 ...

  7. C# ado.net 使用 row_number over() 简单的分页示例

    /// <summary> /// 获取Paging列表 /// </summary> public List<HousesAgentEntity> GetPage ...

  8. SQL Server 事务与锁

    了解事务和锁 事务:保持逻辑数据一致性与可恢复性,必不可少的利器. 锁:多用户访问同一数据库资源时,对访问的先后次序权限管理的一种机制,没有他事务或许将会一塌糊涂,不能保证数据的安全正确读写. 死锁: ...

  9. 周末充电之WPF(一).初试牛刀

    追的剧已经赶上更新的速度了,突然觉得一下子就闲了.趁着这点时间,刚好学点 WPF .看到这边,好多人估计得感叹技术宅约等于单身狗,哈哈.好了,赶紧进入学习状态. 关注 WPF 或者说对它感兴趣其实多半 ...

  10. 修改sqlplus提示符

    如图所示 : 修改 提示符为 username(sid_serial#)@instance_name ,这样其实很方便的 以下是步骤 在11g中glogin.sql 文件是不存在的,取而代之的是 lo ...