Made Node and Egde classes generic so that they can be resued