The longest path search on a topologically sorted weighted oriented acyclic graph, but with the maximum number of graphs for valid paths

I know that the longest / shortest path can be found in linear time by "processing vertices in a topological order and calculating the path length for each vertex as the minimum or maximum length obtained using any of its edges", or more briefly, topologically Sort and find the critical path.

My problem is that I need to add another restriction, the maximum number of edges in a valid path. This complicates the situation because the β€œmaximum length obtained using any of its edges” for a node may include more edges, which means that a later higher node weight may not be available because the maximum edges have already been reached.

What would be the right way to solve this? Can it be solved in linear time?

+4
source share
2 answers

I think I found a solution that still allows topological sorting.

, , , node 1 , .

, node, , , .

+1

. , .

, , , .

-1

All Articles