B Re@sGdddeZdS)c@speZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZdS) DirectedGraphz+A graph structure with directed edges. cCst|_i|_i|_dS)N)set _vertices _forwards _backwards)selfr/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_vendor/resolvelib/structs.py__init__szDirectedGraph.__init__cCs t|jS)N)iterr)rrrr__iter__ szDirectedGraph.__iter__cCs t|jS)N)lenr)rrrr__len__ szDirectedGraph.__len__cCs ||jkS)N)r)rkeyrrr __contains__szDirectedGraph.__contains__cCsBt}t|j|_dd|jD|_dd|jD|_|S)z-Return a shallow copy of this graph. cSsi|]\}}t||qSr)r).0kvrrr sz&DirectedGraph.copy..cSsi|]\}}t||qSr)r)rrrrrrrs)rrrritemsr)rotherrrrcopys  zDirectedGraph.copycCs:||jkrtd|j|t|j|<t|j|<dS)z'Add a new vertex to the graph. z vertex existsN)r ValueErroraddrrr)rrrrrrs    zDirectedGraph.addcCs\|j|x$|j|D]}|j||qWx$|j|D]}|j||q@WdS)zLRemove a vertex from the graph, disconnecting all edges from/to it. N)rremoverpopr)rrftrrrr%s  zDirectedGraph.removecCs||j|ko||j|kS)N)rr)rrrrrr connected.szDirectedGraph.connectedcCs6||jkrt||j|||j||dS)zgConnect two existing vertices. Nothing happens if the vertices are already connected. N)rKeyErrorrrr)rrrrrrconnect1s zDirectedGraph.connectccs4x.|jD] \}}x|D]}||fVqWq WdS)N)rr)rrchildrenrrrr 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