Optimization in Leveled Graphs