3 Buฦ_เใ@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๚/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-1.el7.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/resolvelib/structs.pyฺ__init__szDirectedGraph.__init__cCs t|jƒS)N)ฺiterr)rrrrฺ__iter__ szDirectedGraph.__iter__cCs t|jƒS)N)ฺlenr)rrrrฺ__len__ szDirectedGraph.__len__cCs ||jkS)N)r)rฺkeyrrrฺ __contains__szDirectedGraph.__contains__cCsBtƒ}t|jƒ|_dd„|jjƒDƒ|_dd„|jjƒDƒ|_|S)z-Return a shallow copy of this graph. cSsi|]\}}t|ƒ|“qSr)r)ฺ.0ฺkฺvrrr๚ sz&DirectedGraph.copy..cSsi|]\}}t|ƒ|“qSr)r)rrrrrrrs)rrrrฺitemsr)rฺotherrrrฺcopys  zDirectedGraph.copycCs:||jkrtdƒ‚|jj|ƒtƒ|j|<tƒ|j|<dS)z'Add a new vertex to the graph. z vertex existsN)rฺ ValueErrorฺaddrrr)rrrrrrs    zDirectedGraph.addcCs\|jj|ƒx$|jj|ƒD]}|j|j|ƒqWx$|jj|ƒD]}|j|j|ƒq@WdS)zLRemove a vertex from the graph, disconnecting all edges from/to it. N)rฺremoverฺpopr)rrฺfฺtrrrr%s  zDirectedGraph.removecCs||j|ko||j|kS)N)rr)rrrrrrฺ connected.szDirectedGraph.connectedcCs6||jkrt|ƒ‚|j|j|ƒ|j|j|ƒdS)zgConnect two existing vertices. Nothing happens if the vertices are already connected. N)rฺKeyErrorrrr)rrrrrrฺconnect1s zDirectedGraph.connectccs4x.|jjƒD] \}}x|D]}||fVqWq WdS)N)rr)rrฺchildrenrrrrฺ iter_edges;s zDirectedGraph.iter_edgescCst|j|ƒS)N)r r)rrrrrฺ iter_children@szDirectedGraph.iter_childrencCst|j|ƒS)N)r r)rrrrrฺ iter_parentsCszDirectedGraph.iter_parentsN)ฺ__name__ฺ __module__ฺ __qualname__ฺ__doc__r r r rrrrrrr!r"r#rrrrrs    rN)ฺobjectrrrrrฺs