Блог пользователя peoplePleaser

Автор peoplePleaser, история, 5 лет назад, По-английски

Does there exist a way an efficient method to find the longest path in a DAG among all possible paths? I know how to solve this in $$$O(V*(V+E))$$$ by considering each vertex as the source, and then using topo sort, and iterating over the vertices in that order and update the distances accordingly. Any suggestions/help would be appreciated or maybe we can prove there doesn't exist a faster method. Thanks!

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by peoplePleaser (previous revision, new revision, compare).

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by peoplePleaser (previous revision, new revision, compare).

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

The algorithm you described should be $$$O(V+E)$$$, because you can just relax each edge once in your topo-sort order.