Here is an explaination of legrange interpolation
Here's another that does a better job of describing how to actually compute the function
These are slightly differen't than bezier curves, Bezier curves use control points, for which the final line does not pass through.
Legrange interpolation ensures that each point in the data set is in the final line.
These are good for lines where x is always increasing.
To apply it to a line where x is not always increasing you have to convert your data set into a parameterized data set and interpolate the x and y components independently by t.
Get the lagrange interpolation formula for fx(t) and fy(t).