Modified graph implementation to allow edge weights