Implement undirected weighted graph