U oÏ aàã@sGdd„deƒZdS)c@speZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„ZdS)Ú DirectedGraphz+A graph structure with directed edges. cCstƒ|_i|_i|_dS©N)ÚsetÚ _verticesÚ _forwardsÚ _backwards©Úself©r ú_C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_vendor\resolvelib\structs.pyÚ__init__szDirectedGraph.__init__cCs t|jƒSr)Úiterrrr r r Ú__iter__ szDirectedGraph.__iter__cCs t|jƒSr)Úlenrrr r r Ú__len__ szDirectedGraph.__len__cCs ||jkSr)r©rÚkeyr r r Ú __contains__szDirectedGraph.__contains__cCsBtƒ}t|jƒ|_dd„|j ¡Dƒ|_dd„|j ¡Dƒ|_|S)z-Return a shallow copy of this graph. cSsi|]\}}|t|ƒ“qSr ©r©Ú.0ÚkÚvr r r Ú sz&DirectedGraph.copy..cSsi|]\}}|t|ƒ“qSr rrr r r rs)rrrrÚitemsr)rÚotherr r r Úcopys  zDirectedGraph.copycCs:||jkrtdƒ‚|j |¡tƒ|j|<tƒ|j|<dS)z'Add a new vertex to the graph. z vertex existsN)rÚ ValueErrorÚaddrrrrr r r rs    zDirectedGraph.addcCsT|j |¡|j |¡D]}|j| |¡q|j |¡D]}|j| |¡q:dS)zLRemove a vertex from the graph, disconnecting all edges from/to it. N)rÚremoverÚpopr)rrÚfÚtr r r r%s  zDirectedGraph.removecCs||j|ko||j|kSr)rr©rr r!r r r Ú connected.szDirectedGraph.connectedcCs6||jkrt|ƒ‚|j| |¡|j| |¡dS)zgConnect two existing vertices. Nothing happens if the vertices are already connected. N)rÚKeyErrorrrrr"r r r Úconnect1s zDirectedGraph.connectccs,|j ¡D]\}}|D]}||fVqq dSr)rr)rr Úchildrenr!r r r Ú iter_edges;szDirectedGraph.iter_edgescCst|j|ƒSr)r rrr r r Ú iter_children@szDirectedGraph.iter_childrencCst|j|ƒSr)r rrr r r Ú iter_parentsCszDirectedGraph.iter_parentsN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r r rrrrrr#r%r'r(r)r r r r rs    rN)Úobjectrr r r r Ú