a generic graph class in java