nested vertex class class vertex """lightweight vertex structure for graph ""slots _element def init (selfx) """do not call constructor directly use graph insert vertex( "" self element def element(self) """return element associated with this vertex "" return self element will allow vertex to be map/set key def hash (self) return hash(id(self) nested edge class class edge """lightweight edge structure for graph ""slots _origin _destination _element def init (selfuvx) """do not call constructor directly use graph insert edge( , , "" self origin self destination self element def endpoints(self) """return ( ,vtuple for vertices and "" return (self originself destination def opposite(selfv) """return the vertex that is opposite on this edge "" return self destination if is self origin else self origin def element(self) """return element associated with this edge "" return self element will allow edge to be map/set key def hash (self) return hash(self originself destinationcode fragment vertex and edge classes (to be nested within graph class