Implement the protocols for weighted undirected graph