Completed addVertex function