Suppose I know all of the orbital elements of a particular orbital trajectory (not necessarily an elliptical one). Suppose I know the position and true anomalies at two different points in this trajectory, but not the time it takes to get from one to the other. Assuming a prograde trajectory from point 1 to point 2, how can I determine the time of flight between it takes to get from the first position to the second position? Is there a single algorithm I can use to do this independently of the shape of the trajectory?
Try Kepler's method, which works for orbits with a (1/r$^2$) central force. See Nathaniel Grossman, The Sheer Joy Of Celestial Mechanics, http://spiff.rit.edu/classes/phys440/lectures/ellipse/ellipse.html, or http://www.bogan.ca/orbits/kepler/orbteqtn.html.
Example. For an ellipse around Sol, suppose you know perihelion r$_P$ and aphelion r$_A$. You are given the true anomaly f$_1$, the angle between perihelion and the object's position as measured from the focus occupied by Sol.
Then eccentricity e = (r$_A$-r$_P$)/(r$_A$+r$_P$),
semi-major axis a = (r$_A$+r$_P$)/2, and
period T = 2$\pi$ sqrt(a$^3$/(MG)),
where M is the mass of Sol and G is Newton's constant.
Compute the eccentric anomaly E$_1$, the angle between perihelion and the object's position as measured from the center of the ellipse.
cos(E$_1$) = (e+cos(f$_1$))/(1+ecos(f$_1$))
The travel time deltaT$_1$ from perihelion to f$_1$ is
deltaT$_1$ = (E$_1$-esin(E$_1$))T/(2$\pi$)
Find deltaT$_2$ for the second position. Then the travel time from f$_1$ to f$_2$ = deltaT$_2$ - deltaT$_1$.
The third reference above tabulates the variations needed for circles, parabolae, and hyperbolae.