Considering that there no cycles in the graph.
I have seen the posts where the negation of the weights is suggested and to use Bellman-ford. But I was wondering if the inverse is possible.
Considering that there no cycles in the graph.
I have seen the posts where the negation of the weights is suggested and to use Bellman-ford. But I was wondering if the inverse is possible.
Yes, this works for undirected acyclic graphs. Such a graph is a forest so there is exactly one path between two vertices in the same component. Since there is exactly one path, the shortest path is also the longest path, regardless of what weights you use.
For directed acyclic graphs, it fails for the reason that Eugene points out.