ReddlZddlmZGddeZGddejZGdd eZGd d eZd Z dS) N)collections_abccZeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdS) DirectedGraphz&A graph structure with directed edges.cHt|_i|_i|_dSN)set _vertices _forwards _backwardsselfs /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/resolvelib/structs.py__init__zDirectedGraph.__init__ sc*t|jSr)iterr r s r__iter__zDirectedGraph.__iter__DN###rc*t|jSr)lenr r s r__len__zDirectedGraph.__len__s4>"""rc||jvSr)r rkeys r __contains__zDirectedGraph.__contains__sdn$$rct}t|j|_d|jD|_d|jD|_|S)z$Return a shallow copy of this graph.c4i|]\}}|t|Sr .0kvs r z&DirectedGraph.copy..s$HHHA1c!ffHHHrc4i|]\}}|t|Srr r!s rr%z&DirectedGraph.copy..s$JJJ$!QAs1vvJJJr)rr r r itemsr )rothers rcopyzDirectedGraph.copyshdn--HH1E1E1G1GHHHJJ$/2G2G2I2IJJJ rc||jvrtd|j|t|j|<t|j|<dS)zAdd a new vertex to the graph.z vertex existsN)r ValueErroraddr r r rs rr,zDirectedGraph.addsY $. _-- - 3!ees"uurc.|j||j|D]"}|j||#|j|D]"}|j||#dS)zCRemove a vertex from the graph, disconnecting all edges from/to it.N)r remover popr )rrfts rr.zDirectedGraph.remove's c"""##C(( + +A OA  % %c * * * *$$S)) * *A N1  $ $S ) ) ) ) * *rc>||j|vo||j|vSr)r r rr0r1s r connectedzDirectedGraph.connected/s%DOA&&A1q0A+AArc||jvrt||j|||j||dS)zgConnect two existing vertices. Nothing happens if the vertices are already connected. N)r KeyErrorr r,r r3s rconnectzDirectedGraph.connect2sY DN " "1++  qa    q!!!!!rc#^K|jD]\}}|D]}||fV dSr)r r')rr0childrenr1s r iter_edgeszDirectedGraph.iter_edges<sT>//11  KAx  d    rc6t|j|Sr)rr rs r iter_childrenzDirectedGraph.iter_childrenAsDN3'(((rc6t|j|Sr)rr rs r iter_parentszDirectedGraph.iter_parentsDsDOC()))rN)__name__ __module__ __qualname____doc__rrrrr)r,r.r4r7r:r<r>rrrrrs00 $$$###%%%%%%***BBB""" )))*****rrc>eZdZd dZdZdZeZdZdZdZ dZ dS) IteratorMappingNc4||_||_|pi|_dSr)_mapping _accessor_appends)rmappingaccessorappendss rrzIteratorMapping.__init__Is ! 2 rcNd|j|j|jS)Nz!IteratorMapping({!r}, {!r}, {!r}))formatrFrGrHr s r__repr__zIteratorMapping.__repr__Ns)299 M N M   rc8t|jp|jSr)boolrFrHr s r__bool__zIteratorMapping.__bool__UsDM2T]333rc&||jvp||jvSr)rFrHrs rrzIteratorMapping.__contains__Zsdm#;sdm';;rc |j|}n*#t$rt|j|cYSwxYwt j|||j|dS)Nr)rFr6rrH itertoolschainrGget)rr#r$s r __getitem__zIteratorMapping.__getitem__]s{ * a AA * * * a()) ) ) ) *t~~a00$-2C2CAr2J2JKKKs $77c^fdjD}tjj|S)Nc3.K|]}|jv |VdSrrFr"r#rs r z+IteratorMapping.__iter__..es/CCaAT],B,B,B,B,B,BCCr)rHrTrUrFrmores` rrzIteratorMapping.__iter__ds2CCCC4=CCCt}d333rcrtfdjD}tj|zS)Nc3.K|]}|jv dVdS)rNrZr[s rr\z*IteratorMapping.__len__..is/FFq /E/E1/E/E/E/EFFr)sumrHrrFr]s` rrzIteratorMapping.__len__hs<FFFFdmFFFFF4=!!D((rr) r?r@rArrNrQ __nonzero__rrWrrrrrrDrDHs&&&&    444K<<<LLL444)))))rrDc.eZdZdZdZdZdZeZdZdS)_FactoryIterableViewa:Wrap an iterator factory returned by `find_matches()`. Calling `iter()` on this class would invoke the underlying iterator factory, making it a "collection with ordering" that can be iterated through multiple times, but lacks random access methods presented in built-in Python sequence types. c||_dSr_factory)rfactorys rrz_FactoryIterableView.__init__vs  rcdt|jt|SNz{}({}))rMtyper?listrgr s rrNz_FactoryIterableView.__repr__ys/tDzz2D4I4IJJJrcn t|n#t$rYdSwxYwdS)NFT)nextrg StopIterationr s rrQz_FactoryIterableView.__bool__|sG   ! ! ! !   55 ts !$ 22c*|Srrfr s rrz_FactoryIterableView.__iter__s}}rN r?r@rArBrrNrQrbrrrrrdrdmsd   KKKKrrdc.eZdZdZdZdZdZeZdZdS)_SequenceIterableViewzWrap an iterable returned by find_matches(). This is essentially just a proxy to the underlying sequence that provides the same interface as `_FactoryIterableView`. c||_dSr) _sequence)rsequences rrz_SequenceIterableView.__init__s !rc\dt|j|jSrj)rMrkr?rur s rrNz_SequenceIterableView.__repr__s!tDzz2DNCCCrc*t|jSr)rPrur s rrQz_SequenceIterableView.__bool__rrc*t|jSr)rrur s rrz_SequenceIterableView.__iter__rrNrqrrrrsrssd """DDD$$$K$$$$$rrsct|rt|St|tjst |}t |S)zCBuild an iterable view from the value returned by `find_matches()`.)callablerd isinstancerSequencerlrs)matchess rbuild_iter_viewrsN-#G,,, g7 8 8 w--  ) ))r) rTcompatrobjectrMappingrDrdrsrrrrrs######?*?*?*?*?*F?*?*?*D")")")")")o-")")")J68$$$$$F$$$,*****r