use typedef Edgeweight instead of raw int
move common code into Util header
reformatting code according to guidelines