Model this problem as an optimal path problem that goes between two vertices in a directed graph without cycles.