knapsack and shortest path