optimization in graph