added in and out degree calculations. (fully tested)