Answer the question
In order to leave comments, you need to log in
Algorithm to find the longest path in a directed graph?
Good time of the day, tell me the name of the algorithm that allows you to
Find the longest path in a directed graph, where each edge has a weight.
(not using blunt enumeration)
Answer the question
In order to leave comments, you need to log in
In an acyclic directed graph, the simplest is DFS.
A recursive function that returns the longest path from a given vertex. Remembering the answer - if we have already launched from this vertex, we return the already calculated result. Otherwise, iterate over all edges from this vertex and take the maximum of dfs from the end of the edge + the length of the edge. We remember this maximum and return the result.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question