Search code examples
algorithmgraphpath-finding

longest path in undirected vs directed graph


I need to solve a longest path problem for graphs that are both directed and non-directed (unweighted in both cases). For directed graph, it is pretty easy to find dynamic programming algorithms that are able to solve the problem in pseudopolynomial time, starting at some node, and calculating the longest path for subproblems until every problem has been looked at.

Can I do a similar thing for at non-directed graph? I cant seem to find any litterature about it?


Solution

  • Every directed graph algorithm works on undirected graphs. Simply treat each edge as two directed edges with the same weight.