Implements a weighted graph and node for PR

Note that this is a big copy-paste from the
array based graph. It's not very clean and there
are some ugly parts of this including little use
of generics (welcome to Cassovary).