The longest way graphics

How to find the longest path on a chart? I thought I could use a depth search, but I could not find an easier implementation for it?

+3
source share
4 answers

Like a brainjam , in the comments this is a complete NP. it is only polynomial if the graph is acyclic. if his DAG is even linear. check out wikipage again for more information.

+4
source

try using topological sorting for a directed graph. it is specifically designed for task planning ...

http://en.wikipedia.org/wiki/Topological_sorting

+1
source

DAG G = (V, E), .

node s t.

, opt(I)= max(opt(j)+1) j (j, I) E.

opt (s) = 0 -inf s t ( s, t " t).

, DAG (Directed Acyclic Graph).

, DAG, -1, Bellman Ford, (!) , .

+1

/ node 1/( //),

0

Source: https://habr.com/ru/post/1738767/


All Articles