[graph-tool] optimize a function based on iterate_sync