improve sa_optimal_graph