Characterizing the interval function of a connected graph