precise and conservative buildFlowFunction