pathdirected-acyclic-graphsshortest

Shortest positive path in a directed acyclic graph


We are given a directed acyclic graph with arbitrary weights on edges and two specific nodes, s and t, where in-degree of s and out-degree of t is 0. How to determine the shortest path from s to t that has positive cost?


Solution

  • Use a modified Bellman-Ford, which removes edges from the graph if a resulting shortest path cost is <0 until you reach a cost, that is not <0.