Refactoring of Pair class
WeightedEdge class