def get edge(selfuv)"""return the edge from to vor none if not adjacent ""returns none if not adjacent return self outgoing[uget(vdef degree(selfvoutgoing=true)"""return number of (outgoingedges incident to vertex in the graph if graph is directedoptional parameter used to count incoming edges ""adj self outgoing if outgoing else self incoming return len(adj[ ]def incident edges(selfvoutgoing=true)"""return all (outgoingedges incident to vertex in the graph if graph is directedoptional parameter used to request incoming edges ""adj self outgoing if outgoing else self incoming for edge in adj[vvalues)yield edge def insert vertex(selfx=none)"""insert and return new vertex with element "" self vertex(xself outgoing[vif self is directed)need distinct map for incoming edges self incoming[vreturn def insert edge(selfuvx=none)"""insert and return new edge from to with auxiliary element "" self edge(uvxself outgoing[ ][ve self incoming[ ][ue code fragment graph class definition (continued from code fragment we omit error-checking of parameters for brevity