Generalizing Test-time Compute-optimal Scaling as an Optimizable Graph