A weighted graph implementation