Collect all edge and gradient related functions in one file.

* Also move edge and gradient related tests to their own file.