writing piecewise functions from graph - Search