4 ms·
That doesn't actually work, because a DAG only lacks directed cycles. Consider: /-3-> D A -1-> B -1-> C \------4------^ In this case, the longest path i
by a1369209993 3y ago
That doesn't actually work, because a DAG only lacks directed cycles. Consider:
/-3-> D
A -1-> B -1-> C
\------4------^
In this case, the longest path is A-C, but C will be held at level 2 by B, leaving D lowest at level 3. This works for a fully-acyclic directed graph (eg a tree), but not for a directed-acyclic directed graph. It can also find the node whose shortest path is the longest (so longest shortest path, minimax style). (It also works for a acyclic undirected graph, as illustrated at [0], but that's a bit tangential.)
0: https://www.youtube.com/watch?v=wGrOPSBPpyk https://www.youtube.com/watch?v=wGrOPSBPpyk
- mikhailfranco 3y agoYes, you are completely correct. It only works for fruit trees.
- a1369209993 3y agoActually it works for all trees, fruit or otherwise (and also for some non-tree graphs, though I'd have trouble giving a useful category more general than tree).