o
    ˷eo<                     @   s   d Z ddlZddlmZ g dZG dd deZG dd deZG d	d
 d
eZG dd deZG dd deZ	G dd deZ
G dd de	ZG dd deZG dd deZG dd deZG dd deZdS )zViews of core data structures such as nested Mappings (e.g. dict-of-dicts).
These ``Views`` often restrict element access, with either the entire view or
layers of nested mappings being read-only.
    N)Mapping)	AtlasViewAdjacencyViewMultiAdjacencyView
UnionAtlasUnionAdjacencyUnionMultiInnerUnionMultiAdjacencyFilterAtlasFilterAdjacencyFilterMultiInnerFilterMultiAdjacencyc                   @   \   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd ZdS )r   aH  An AtlasView is a Read-only Mapping of Mappings.

    It is a View into a dict-of-dict data structure.
    The inner level of dict is read-write. But the
    outer level is read-only.

    See Also
    ========
    AdjacencyView: View into dict-of-dict-of-dict
    MultiAdjacencyView: View into dict-of-dict-of-dict-of-dict
    _atlasc                 C   s
   d| j iS Nr   r   self r   Q/var/www/ideatree/venv/lib/python3.10/site-packages/networkx/classes/coreviews.py__getstate__&      
zAtlasView.__getstate__c                 C   s   |d | _ d S r   r   r   stater   r   r   __setstate__)      zAtlasView.__setstate__c                 C   s
   || _ d S Nr   )r   dr   r   r   __init__,   r   zAtlasView.__init__c                 C   
   t | jS r   )lenr   r   r   r   r   __len__/   r   zAtlasView.__len__c                 C   r   r   )iterr   r   r   r   r   __iter__2   r   zAtlasView.__iter__c                 C   s
   | j | S r   r   r   keyr   r   r   __getitem__5   r   zAtlasView.__getitem__c                        fdd j D S )Nc                       i | ]	}| |   qS r   copy.0nr   r   r   
<dictcomp>9       z"AtlasView.copy.<locals>.<dictcomp>r   r   r   r   r   r*   8      zAtlasView.copyc                 C   r   r   )strr   r   r   r   r   __str__;   r   zAtlasView.__str__c                 C   s   | j j d| jdS )N())	__class____name__r   r   r   r   r   __repr__>      zAtlasView.__repr__Nr6   
__module____qualname____doc__	__slots__r   r   r   r!   r#   r&   r*   r2   r7   r   r   r   r   r      s    r   c                   @   $   e Zd ZdZdZdd Zdd ZdS )r   aJ  An AdjacencyView is a Read-only Map of Maps of Maps.

    It is a View into a dict-of-dict-of-dict data structure.
    The inner level of dict is read-write. But the
    outer levels are read-only.

    See Also
    ========
    AtlasView: View into dict-of-dict
    MultiAdjacencyView: View into dict-of-dict-of-dict-of-dict
    r   c                 C      t | j| S r   )r   r   r   namer   r   r   r&   Q   r   zAdjacencyView.__getitem__c                    r'   )Nc                    r(   r   r)   r+   r   r   r   r.   U   r/   z&AdjacencyView.copy.<locals>.<dictcomp>r   r   r   r   r   r*   T   r0   zAdjacencyView.copyNr6   r:   r;   r<   r=   r&   r*   r   r   r   r   r   B   
    r   c                   @   r>   )r   aR  An MultiAdjacencyView is a Read-only Map of Maps of Maps of Maps.

    It is a View into a dict-of-dict-of-dict-of-dict data structure.
    The inner level of dict is read-write. But the
    outer levels are read-only.

    See Also
    ========
    AtlasView: View into dict-of-dict
    AdjacencyView: View into dict-of-dict-of-dict
    r   c                 C   r?   r   )r   r   r@   r   r   r   r&   g   r   zMultiAdjacencyView.__getitem__c                    r'   )Nc                    r(   r   r)   r+   r   r   r   r.   k   r/   z+MultiAdjacencyView.copy.<locals>.<dictcomp>r   r   r   r   r   r*   j   r0   zMultiAdjacencyView.copyNrB   r   r   r   r   r   X   rC   r   c                   @   r   )r   a  A read-only union of two atlases (dict-of-dict).

    The two dict-of-dicts represent the inner dict of
    an Adjacency:  `G.succ[node]` and `G.pred[node]`.
    The inner level of dict of both hold attribute key:value
    pairs and is read-write. But the outer level is read-only.

    See Also
    ========
    UnionAdjacency: View into dict-of-dict-of-dict
    UnionMultiAdjacency: View into dict-of-dict-of-dict-of-dict
    _succ_predc                 C      | j | jdS NrD   rD   r   r   r   r   r   ~   r   zUnionAtlas.__getstate__c                 C      |d | _ |d | _d S NrE   rF   rD   r   r   r   r   r         
zUnionAtlas.__setstate__c                 C      || _ || _d S r   rD   r   succpredr   r   r   r         
zUnionAtlas.__init__c                 C   s   t | jt | j S r   )r    rE   rF   r   r   r   r   r!      r0   zUnionAtlas.__len__c                 C   s    t t| j t| j B S r   )r"   setrE   keysrF   r   r   r   r   r#      s    zUnionAtlas.__iter__c                 C   s*   z| j | W S  ty   | j|  Y S w r   )rE   KeyErrorrF   r$   r   r   r   r&      s
   zUnionAtlas.__getitem__c                 C   sP   dd | j  D }| j D ]\}}||v r|| | q| ||< q|S )Nc                 S   s   i | ]	\}}||  qS r   r)   )r,   nbrddr   r   r   r.      r/   z#UnionAtlas.copy.<locals>.<dictcomp>)rE   itemsrF   updater*   )r   resultrT   rU   r   r   r   r*      s   zUnionAtlas.copyc                       t  fdd D S )Nc                       i | ]}| | qS r   r   r,   rT   r   r   r   r.          z&UnionAtlas.__str__.<locals>.<dictcomp>r1   r   r   r   r   r2      r8   zUnionAtlas.__str__c                 C      | j j d| jd| jdS Nr3   z, r4   r5   r6   rE   rF   r   r   r   r   r7         zUnionAtlas.__repr__Nr9   r   r   r   r   r   n   s    	r   c                   @   r   )r   a3  A read-only union of dict Adjacencies as a Map of Maps of Maps.

    The two input dict-of-dict-of-dicts represent the union of
    `G.succ` and `G.pred`. Return values are UnionAtlas
    The inner level of dict is read-write. But the
    middle and outer levels are read-only.

    succ : a dict-of-dict-of-dict {node: nbrdict}
    pred : a dict-of-dict-of-dict {node: nbrdict}
    The keys for the two dicts should be the same

    See Also
    ========
    UnionAtlas: View into dict-of-dict
    UnionMultiAdjacency: View into dict-of-dict-of-dict-of-dict
    rD   c                 C   rG   rH   rD   r   r   r   r   r      r   zUnionAdjacency.__getstate__c                 C   rI   rJ   rD   r   r   r   r   r      rK   zUnionAdjacency.__setstate__c                 C   s4   t t| t| A dksJ || _|| _d S )Nr   )r    rQ   rR   rE   rF   rM   r   r   r   r      s   $
zUnionAdjacency.__init__c                 C   r   r   )r    rE   r   r   r   r   r!      r   zUnionAdjacency.__len__c                 C   r   r   )r"   rE   r   r   r   r   r#      r   zUnionAdjacency.__iter__c                 C      t | j| | j| S r   )r   rE   rF   )r   rT   r   r   r   r&      r8   zUnionAdjacency.__getitem__c                    r'   )Nc                    r(   r   r)   r+   r   r   r   r.      r/   z'UnionAdjacency.copy.<locals>.<dictcomp>)rE   r   r   r   r   r*      r0   zUnionAdjacency.copyc                    rY   )Nc                    rZ   r   r   r[   r   r   r   r.      r\   z*UnionAdjacency.__str__.<locals>.<dictcomp>r]   r   r   r   r   r2      r8   zUnionAdjacency.__str__c                 C   r^   r_   r`   r   r   r   r   r7      ra   zUnionAdjacency.__repr__Nr9   r   r   r   r   r      s    r   c                   @   r>   )r   a  A read-only union of two inner dicts of MultiAdjacencies.

    The two input dict-of-dict-of-dicts represent the union of
    `G.succ[node]` and `G.pred[node]` for MultiDiGraphs.
    Return values are UnionAtlas.
    The inner level of dict is read-write. But the outer levels are read-only.

    See Also
    ========
    UnionAtlas: View into dict-of-dict
    UnionAdjacency:  View into dict-of-dict-of-dict
    UnionMultiAdjacency:  View into dict-of-dict-of-dict-of-dict
    r   c                 C   sR   || j v }|| jv }|r!|rt| j | | j| S t| j | i S ti | j| S r   )rE   rF   r   )r   nodein_succin_predr   r   r   r&      s   

zUnionMultiInner.__getitem__c                    s.   t  j t  j B } fdd|D S )Nc                    r(   r   r)   r+   r   r   r   r.      r/   z(UnionMultiInner.copy.<locals>.<dictcomp>)rQ   rE   rR   rF   )r   nodesr   r   r   r*      s   zUnionMultiInner.copyNrB   r   r   r   r   r      s
    	r   c                   @   s   e Zd ZdZdZdd ZdS )r	   a  A read-only union of two dict MultiAdjacencies.

    The two input dict-of-dict-of-dict-of-dicts represent the union of
    `G.succ` and `G.pred` for MultiDiGraphs. Return values are UnionAdjacency.
    The inner level of dict is read-write. But the outer levels are read-only.

    See Also
    ========
    UnionAtlas:  View into dict-of-dict
    UnionMultiInner:  View into dict-of-dict-of-dict
    r   c                 C   rb   r   )r   rE   rF   )r   rc   r   r   r   r&     r8   zUnionMultiAdjacency.__getitem__N)r6   r:   r;   r<   r=   r&   r   r   r   r   r	      s    r	   c                   @   D   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )r
   c                 C   rL   r   )r   NODE_OK)r   r   rh   r   r   r   r     rP   zFilterAtlas.__init__c                 C      t dd | D S )Nc                 s       | ]}d V  qdS    Nr   r+   r   r   r   	<genexpr>      z&FilterAtlas.__len__.<locals>.<genexpr>sumr   r   r   r   r!        zFilterAtlas.__len__c                    d   zdt  jj t  jk }W n ty   d}Y nw |r( fdd jjD S  fdd jD S )N   Fc                 3       | ]
}| j v r|V  qd S r   r   r+   r   r   r   rm         z'FilterAtlas.__iter__.<locals>.<genexpr>c                 3       | ]
}  |r|V  qd S r   rh   r+   r   r   r   rm     ru   r    rh   rf   r   AttributeErrorr   node_ok_shorterr   r   r   r#        zFilterAtlas.__iter__c                 C   s.   || j v r| |r| j | S td| d)NKey 
 not found)r   rh   rS   r$   r   r   r   r&     s   
zFilterAtlas.__getitem__c                    t   t dt zdt jj t jk }W n ty    d}Y nw |r. fdd jjD S  fdd j D S )NzFilterAtlas.copy is deprecated.
It will be removed in NetworkX 3.0.
Please open an Issue on https://github.com/networkx/networkx/issues
if you use this feature. We think that no one does use it.rs   Fc                    s"   i | ]}| j v r| j | qS r   r   )r,   ur   r   r   r.   1     " z$FilterAtlas.copy.<locals>.<dictcomp>c                    s    i | ]\}}  |r||qS r   rw   )r,   r   r   r   r   r   r.   2  s     	warningswarnDeprecationWarningr    rh   rf   r   ry   rV   rz   r   r   r   r*   "  s   	zFilterAtlas.copyc                    rY   )Nc                    rZ   r   r   r[   r   r   r   r.   5  r\   z'FilterAtlas.__str__.<locals>.<dictcomp>r]   r   r   r   r   r2   4  r8   zFilterAtlas.__str__c                 C   r^   r_   )r5   r6   r   rh   r   r   r   r   r7   7  ra   zFilterAtlas.__repr__N
r6   r:   r;   r   r!   r#   r&   r*   r2   r7   r   r   r   r   r
     s    	r
   c                   @   rg   )r   c                 C   s   || _ || _|| _d S r   )r   rh   EDGE_OK)r   r   rh   r   r   r   r   r   <  s   
zFilterAdjacency.__init__c                 C   ri   )Nc                 s   rj   rk   r   r+   r   r   r   rm   B  rn   z*FilterAdjacency.__len__.<locals>.<genexpr>ro   r   r   r   r   r!   A  rq   zFilterAdjacency.__len__c                    rr   )Nrs   Fc                 3   rt   r   r   r+   r   r   r   rm   J  ru   z+FilterAdjacency.__iter__.<locals>.<genexpr>c                 3   rv   r   rw   r+   r   r   r   rm   K  ru   rx   rz   r   r   r   r#   D  r|   zFilterAdjacency.__iter__c                    B    j v r r fdd}tj   |S td  d)Nc                    s    | o
 | S r   rh   r   )rT   rc   r   r   r   new_node_okP  r8   z0FilterAdjacency.__getitem__.<locals>.new_node_okr}   r~   r   rh   r
   rS   )r   rc   r   r   r   r   r&   M     zFilterAdjacency.__getitem__c                    r   )NzFilterAdjacency.copy is deprecated.
It will be removed in NetworkX 3.0.
Please open an Issue on https://github.com/networkx/networkx/issues
if you use this feature. We think that no one does use it.rs   Fc                    6   i | ]  j v r  fd dj    D qS )c                    ,   i | ]\}}  |r |r||qS r   r   r,   vr   r   r   r   r   r.   g  s    
3FilterAdjacency.copy.<locals>.<dictcomp>.<dictcomp>r   rV   r,   r   r   r   r.   f  s    
z(FilterAdjacency.copy.<locals>.<dictcomp>c                    4   i | ]\ }  r  fd d| D qS )c                    r   r   r   r   r   r   r   r.   q  s   , r   rh   rV   r,   nbrsr   r   r   r.   p      r   rz   r   r   r   r*   W  s    	


zFilterAdjacency.copyc                    rY   )Nc                    rZ   r   r   r[   r   r   r   r.   w  r\   z+FilterAdjacency.__str__.<locals>.<dictcomp>r]   r   r   r   r   r2   v  r8   zFilterAdjacency.__str__c                 C   s*   | j j}| d| jd| jd| jdS r_   )r5   r6   r   rh   r   r@   r   r   r   r7   y  s   "zFilterAdjacency.__repr__Nr   r   r   r   r   r   ;  s    	
r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )r   c                 #   s    zdt  jj t  jk }W n ty   d}Y nw |r* fdd jjD }n
 fdd jD }|D ]}d} j| D ]} ||rKd} nq?|du rS|V  q6d S )Nrs   Fc                 3   rt   r   r   r+   r   r   r   rm     ru   z,FilterMultiInner.__iter__.<locals>.<genexpr>c                 3   rv   r   rw   r+   r   r   r   rm     ru   T)r    rh   rf   r   ry   r   )r   r{   my_nodesr-   some_keys_okr%   r   r   r   r#     s(   zFilterMultiInner.__iter__c                    r   )Nc                    s     | S r   r   )r%   rT   r   r   r   r     s   z1FilterMultiInner.__getitem__.<locals>.new_node_okr}   r~   r   )r   rT   r   r   r   r   r&     r   zFilterMultiInner.__getitem__c                    r   )NzFilterMultiInner.copy is deprecated.
It will be removed in NetworkX 3.0.
Please open an Issue on https://github.com/networkx/networkx/issues
if you use this feature. We think that no one does use it.rs   Fc                    r   )c                    "   i | ]\}}  |r||qS r   r   r,   kr   r   r   r   r   r.     r   4FilterMultiInner.copy.<locals>.<dictcomp>.<dictcomp>r   r   r   r   r   r.     s
    
z)FilterMultiInner.copy.<locals>.<dictcomp>c                    r   )c                    r   r   r   r   r   r   r   r.     r   r   r   r   r   r   r   r.     r   r   rz   r   r   r   r*     s    	

zFilterMultiInner.copyN)r6   r:   r;   r#   r&   r*   r   r   r   r   r   ~  s    
r   c                   @   s   e Zd Zdd Zdd ZdS )r   c                    sF    j v r r fdd}tj   j|S td  d)Nc                    s    | o | |S r   r   )rT   r%   r   r   r   edge_ok  s   z1FilterMultiAdjacency.__getitem__.<locals>.edge_okr}   r~   )r   rh   r   rS   )r   rc   r   r   r   r   r&     s   z FilterMultiAdjacency.__getitem__c                    sz   t dt zdtjj tjk }W n ty    d}Y nw |r1jj  fdd D S fddj D S )NzFilterMultiAdjacency.copy is deprecated.
It will be removed in NetworkX 3.0.
Please open an Issue on https://github.com/networkx/networkx/issues
if you use this feature. We think that no one does use it.rs   Fc                    s8   i | ]  j v r  fd dj    D qS )c                    s4   i | ]\ } v r  fd d|  D qS )c                    $   i | ]\}}  |r||qS r   r   r   r   r   r   r   r   r.        $ CFilterMultiAdjacency.copy.<locals>.<dictcomp>.<dictcomp>.<dictcomp>)rV   r,   kd)r   r   r   r   r   r.     s
    8FilterMultiAdjacency.copy.<locals>.<dictcomp>.<dictcomp>r   r   r   r   r   r   r.     s    
z-FilterMultiAdjacency.copy.<locals>.<dictcomp>c                    r   )c                    s6   i | ]\ }  r  fd d| D qS )c                    r   r   r   r   r   r   r   r.     r   r   r   r   r   r   r   r.     s    r   r   r   r   r   r   r.     s    r   rz   r   r   r   r*     s"   	
	zFilterMultiAdjacency.copyN)r6   r:   r;   r&   r*   r   r   r   r   r     s    
r   )r<   r   collections.abcr   __all__r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   <module>   s    +740C8