
     f                         d dl Z ddlmZ  G d de          Z G d dej                  Z G d d	e          Z G d
 de          Zd Z	dS )    N   )collections_abcc                   Z    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )DirectedGraphz&A graph structure with directed edges.c                 H    t                      | _        i | _        i | _        d S N)set	_vertices	_forwards
_backwardsselfs    a/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/pip/_vendor/resolvelib/structs.py__init__zDirectedGraph.__init__	   s        c                 *    t          | j                  S r   )iterr
   r   s    r   __iter__zDirectedGraph.__iter__       DN###r   c                 *    t          | j                  S r   )lenr
   r   s    r   __len__zDirectedGraph.__len__   s    4>"""r   c                     || j         v S r   )r
   r   keys     r   __contains__zDirectedGraph.__contains__   s    dn$$r   c                     t                      }t          | j                  |_        d | j                                        D             |_        d | j                                        D             |_        |S )z$Return a shallow copy of this graph.c                 4    i | ]\  }}|t          |          S  r	   .0kvs      r   
<dictcomp>z&DirectedGraph.copy.<locals>.<dictcomp>   s$    HHHA1c!ffHHHr   c                 4    i | ]\  }}|t          |          S r   r    r!   s      r   r%   z&DirectedGraph.copy.<locals>.<dictcomp>   s$    JJJ$!QAs1vvJJJr   )r   r	   r
   r   itemsr   )r   others     r   copyzDirectedGraph.copy   sh    dn--HH1E1E1G1GHHHJJ$/2G2G2I2IJJJr   c                     || j         v rt          d          | j                             |           t                      | j        |<   t                      | j        |<   dS )zAdd a new vertex to the graph.zvertex existsN)r
   
ValueErroraddr	   r   r   r   s     r   r,   zDirectedGraph.add   sY    $.  _---3!ees"uur   c                 .   | j                             |           | j                            |          D ]"}| j        |                             |           #| j                            |          D ]"}| j        |                             |           #dS )zCRemove a vertex from the graph, disconnecting all edges from/to it.N)r
   remover   popr   )r   r   fts       r   r.   zDirectedGraph.remove'   s    c"""##C(( 	+ 	+AOA%%c****$$S)) 	* 	*AN1$$S))))	* 	*r   c                 >    || j         |         v o|| j        |         v S r   )r   r   r   r0   r1   s      r   	connectedzDirectedGraph.connected/   s%    DOA&&A1q0A+AAr   c                     || j         vrt          |          | j        |                             |           | j        |                             |           dS )zgConnect two existing vertices.

        Nothing happens if the vertices are already connected.
        N)r
   KeyErrorr   r,   r   r3   s      r   connectzDirectedGraph.connect2   sY    
 DN""1++qa   q!!!!!r   c              #   ^   K   | j                                         D ]\  }}|D ]}||fV  	d S r   )r   r'   )r   r0   childrenr1   s       r   
iter_edgeszDirectedGraph.iter_edges<   sT      >//11 	 	KAx  d



	 	r   c                 6    t          | j        |                   S r   )r   r   r   s     r   iter_childrenzDirectedGraph.iter_childrenA   s    DN3'(((r   c                 6    t          | j        |                   S r   )r   r   r   s     r   iter_parentszDirectedGraph.iter_parentsD   s    DOC()))r   N)__name__
__module____qualname____doc__r   r   r   r   r)   r,   r.   r4   r7   r:   r<   r>   r   r   r   r   r      s        00  
$ $ $# # #% % %  % % %* * *B B B" " "  
) ) )* * * * *r   r   c                   >    e Zd Zd	dZd Zd ZeZd Zd Zd Z	d Z
dS )
IteratorMappingNc                 4    || _         || _        |pi | _        d S r   )_mapping	_accessor_appends)r   mappingaccessorappendss       r   r   zIteratorMapping.__init__I   s    !2r   c                 N    d                     | j        | j        | j                  S )Nz!IteratorMapping({!r}, {!r}, {!r}))formatrF   rG   rH   r   s    r   __repr__zIteratorMapping.__repr__N   s)    299MNM
 
 	
r   c                 8    t          | j        p| j                  S r   )boolrF   rH   r   s    r   __bool__zIteratorMapping.__bool__U   s    DM2T]333r   c                 &    || j         v p|| j        v S r   )rF   rH   r   s     r   r   zIteratorMapping.__contains__Z   s    dm#;sdm';;r   c                     	 | j         |         }n*# t          $ r t          | j        |                   cY S w xY wt	          j        |                     |          | j                            |d                    S )Nr   )rF   r6   r   rH   	itertoolschainrG   get)r   r#   r$   s      r   __getitem__zIteratorMapping.__getitem__]   s{    	*a AA 	* 	* 	*a()))))	*t~~a00$-2C2CAr2J2JKKKs    $77c                 ^      fd j         D             }t          j         j        |          S )Nc              3   .   K   | ]}|j         v|V  d S r   rF   r"   r#   r   s     r   	<genexpr>z+IteratorMapping.__iter__.<locals>.<genexpr>e   s/      CCaAT],B,B,B,B,B,BCCr   )rH   rT   rU   rF   r   mores   ` r   r   zIteratorMapping.__iter__d   s2    CCCC4=CCCt}d333r   c                 r     t           fd j        D                       }t           j                  |z   S )Nc              3   .   K   | ]}|j         vd V  dS )r   NrZ   r[   s     r   r\   z*IteratorMapping.__len__.<locals>.<genexpr>i   s/      FFq/E/E1/E/E/E/EFFr   )sumrH   r   rF   r]   s   ` r   r   zIteratorMapping.__len__h   s<    FFFFdmFFFFF4=!!D((r   r   )r?   r@   rA   r   rN   rQ   __nonzero__r   rW   r   r   r   r   r   rD   rD   H   s        & & & &

 
 
4 4 4 K< < <L L L4 4 4) ) ) ) )r   rD   c                   .    e Zd ZdZd Zd Zd ZeZd ZdS )_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                     || _         d S r   _factory)r   factorys     r   r   z_FactoryIterableView.__init__v   s    r   c                     d                     t          |           j        t          |                                                     S Nz{}({}))rM   typer?   listrg   r   s    r   rN   z_FactoryIterableView.__repr__y   s/    tDzz2D4I4IJJJr   c                 n    	 t          |                                            n# t          $ r Y dS w xY wdS )NFT)nextrg   StopIterationr   s    r   rQ   z_FactoryIterableView.__bool__|   sG    	!!!! 	 	 	55	ts   !$ 
22c                 *    |                                  S r   rf   r   s    r   r   z_FactoryIterableView.__iter__   s    }}r   N	r?   r@   rA   rB   r   rN   rQ   rb   r   r   r   r   rd   rd   m   sd              K K K   K    r   rd   c                   .    e Zd ZdZd Zd Zd ZeZd ZdS )_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                     || _         d S r   )	_sequence)r   sequences     r   r   z_SequenceIterableView.__init__   s    !r   c                 \    d                     t          |           j        | j                  S rj   )rM   rk   r?   ru   r   s    r   rN   z_SequenceIterableView.__repr__   s!    tDzz2DNCCCr   c                 *    t          | j                  S r   )rP   ru   r   s    r   rQ   z_SequenceIterableView.__bool__   r   r   c                 *    t          | j                  S r   )r   ru   r   s    r   r   z_SequenceIterableView.__iter__   r   r   Nrq   r   r   r   rs   rs      sd         " " "D D D$ $ $ K$ $ $ $ $r   rs   c                     t          |           rt          |           S t          | t          j                  st          |           } t          |           S )zCBuild an iterable view from the value returned by `find_matches()`.)callablerd   
isinstancer   Sequencerl   rs   )matchess    r   build_iter_viewr      sN     -#G,,,g788  w-- )))r   )
rT   compatr   objectr   MappingrD   rd   rs   r   r   r   r   <module>r      s        # # # # # #?* ?* ?* ?* ?*F ?* ?* ?*D") ") ") ") ")o- ") ") ")J    6   8$ $ $ $ $F $ $ $,* * * * *r   