
    wgW3                        d Z ddlmZ g dZ G d de      Z G d de      Z G d d	e      Z G d
 de      Z G d de      Z G d de      Z	 G d de      Z
 G d de      Z G d de      Z G d de      Z G d de      Zy)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.
    )Mapping)	AtlasViewAdjacencyViewMultiAdjacencyView
UnionAtlasUnionAdjacencyUnionMultiInnerUnionMultiAdjacencyFilterAtlasFilterAdjacencyFilterMultiInnerFilterMultiAdjacencyc                   J    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y)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                     d| j                   iS Nr   r   selfs    _/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/networkx/classes/coreviews.py__getstate__zAtlasView.__getstate__&   s    $++&&    c                     |d   | _         y r   r   r   states     r   __setstate__zAtlasView.__setstate__)   s    Hor   c                     || _         y Nr   )r   ds     r   __init__zAtlasView.__init__,   s	    r   c                 ,    t        | j                        S r   )lenr   r   s    r   __len__zAtlasView.__len__/       4;;r   c                 ,    t        | j                        S r   )iterr   r   s    r   __iter__zAtlasView.__iter__2   s    DKK  r   c                      | j                   |   S r   r   r   keys     r   __getitem__zAtlasView.__getitem__5   s    {{3r   c                 d    | j                   D ci c]  }|| |   j                          c}S c c}w r   r   copyr   ns     r   r.   zAtlasView.copy8   )    +/;;7a47<<>!777   -c                 ,    t        | j                        S r   )strr   r   s    r   __str__zAtlasView.__str__;   r$   r   c                 N    | j                   j                   d| j                  dS )N())	__class____name__r   r   s    r   __repr__zAtlasView.__repr__>   s$    ..))*!DKK?!<<r   Nr:   
__module____qualname____doc__	__slots__r   r   r    r#   r'   r+   r.   r5   r;    r   r   r   r      s;    
 I'& ! 8 =r   r   c                        e Zd ZdZdZd Zd Zy)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
    rA   c                 2    t        | j                  |         S r   )r   r   r   names     r   r+   zAdjacencyView.__getitem__Q   s    T*++r   c                 d    | j                   D ci c]  }|| |   j                          c}S c c}w r   r-   r/   s     r   r.   zAdjacencyView.copyT   r1   r2   Nr:   r=   r>   r?   r@   r+   r.   rA   r   r   r   r   B   s    
 I,8r   r   c                        e Zd ZdZdZd Zd Zy)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
    rA   c                 2    t        | j                  |         S r   )r   r   rD   s     r   r+   zMultiAdjacencyView.__getitem__g   s    T[[.//r   c                 d    | j                   D ci c]  }|| |   j                          c}S c c}w r   r-   r/   s     r   r.   zMultiAdjacencyView.copyj   r1   r2   NrG   rA   r   r   r   r   X   s    
 I08r   r   c                   J    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y)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                 4    | j                   | j                  dS NrL   rL   r   s    r   r   zUnionAtlas.__getstate__~       djj99r   c                 ,    |d   | _         |d   | _        y NrM   rN   rL   r   s     r   r   zUnionAtlas.__setstate__       7^
7^
r   c                      || _         || _        y r   rL   r   succpreds      r   r    zUnionAtlas.__init__   s    

r   c                 ~    t        | j                  j                         | j                  j                         z        S r   )r"   rM   keysrN   r   s    r   r#   zUnionAtlas.__len__   s(    4::??$tzz'8899r   c                     t        t        | j                  j                               t        | j                  j                               z        S r   )r&   setrM   rZ   rN   r   s    r   r'   zUnionAtlas.__iter__   s2    C

)*S1B-CCDDr   c                 ^    	 | j                   |   S # t        $ r | j                  |   cY S w xY wr   )rM   KeyErrorrN   r)   s     r   r+   zUnionAtlas.__getitem__   s2    	#::c?" 	#::c?"	#s    ,,c                 $   | j                   j                         D ci c]  \  }}||j                          }}}| j                  j                         D ]1  \  }}||v r||   j	                  |       |j                         ||<   3 |S c c}}w r   )rM   itemsr.   rN   update)r   nbrddresults       r   r.   zUnionAtlas.copy   s    04

0@0@0BCWS"#rwwy.CCzz'') 	(GCf}s""2& ggis		(
  Ds   Bc                 F    t        | D ci c]  }|| |   
 c}      S c c}w r   r4   r   rb   s     r   r5   zUnionAtlas.__str__   #    d3sCcN3443   c                 h    | j                   j                   d| j                  d| j                  dS Nr7   z, r8   r9   r:   rM   rN   r   s    r   r;   zUnionAtlas.__repr__   .    ..))*!DJJ>DJJ>KKr   Nr<   rA   r   r   r   r   n   s=     #I:$:E#5Lr   r   c                   J    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y)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
    rL   c                 4    | j                   | j                  dS rP   rL   r   s    r   r   zUnionAdjacency.__getstate__   rQ   r   c                 ,    |d   | _         |d   | _        y rS   rL   r   s     r   r   zUnionAdjacency.__setstate__   rT   r   c                     t        t        |j                               t        |j                               z        dk(  sJ || _        || _        y )Nr   )r"   r\   rZ   rM   rN   rV   s      r   r    zUnionAdjacency.__init__   s>    3tyy{#c$))+&6671<<<

r   c                 ,    t        | j                        S r   )r"   rM   r   s    r   r#   zUnionAdjacency.__len__   s    4::r   c                 ,    t        | j                        S r   )r&   rM   r   s    r   r'   zUnionAdjacency.__iter__   s    DJJr   c                 N    t        | j                  |   | j                  |         S r   )r   rM   rN   rg   s     r   r+   zUnionAdjacency.__getitem__   s    $**S/4::c?;;r   c                 d    | j                   D ci c]  }|| |   j                          c}S c c}w r   )rM   r.   r/   s     r   r.   zUnionAdjacency.copy   s)    +/::6a47<<>!666r2   c                 F    t        | D ci c]  }|| |   
 c}      S c c}w r   rf   rg   s     r   r5   zUnionAdjacency.__str__   rh   ri   c                 h    | j                   j                   d| j                  d| j                  dS rk   rl   r   s    r   r;   zUnionAdjacency.__repr__   rm   r   Nr<   rA   r   r   r   r      s<    " #I:$ <75Lr   r   c                        e Zd ZdZdZd Zd Zy)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
    rA   c                     || j                   v }|| j                  v }|rA|r&t        | j                   |   | j                  |         S t        | j                   |   i       S t        i | j                  |         S r   )rM   rN   r   )r   nodein_succin_preds       r   r+   zUnionMultiInner.__getitem__   so    $**$$**$!$**T"2DJJt4DEEdjj.33"djj.//r   c                     t        | j                  j                               t        | j                  j                               z  }|D ci c]  }|| |   j	                          c}S c c}w r   )r\   rM   rZ   rN   r.   )r   nodesr0   s      r   r.   zUnionMultiInner.copy   sO    DJJOO%&TZZ__->)??+01a47<<>!111s   A*NrG   rA   r   r   r	   r	      s     I02r   r	   c                       e Zd ZdZdZd Zy)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
    rA   c                 N    t        | j                  |   | j                  |         S r   )r	   rM   rN   )r   rz   s     r   r+   zUnionMultiAdjacency.__getitem__  s!    tzz$/D1ABBr   N)r:   r=   r>   r?   r@   r+   rA   r   r   r
   r
      s    
 ICr   r
   c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	r   a'  A read-only Mapping of Mappings with filtering criteria for nodes.

    It is a view into a dict-of-dict data structure, and it selects only
    nodes that meet the criteria defined by ``NODE_OK``.

    See Also
    ========
    FilterAdjacency
    FilterMultiInner
    FilterMultiAdjacency
    c                      || _         || _        y r   )r   NODE_OK)r   r   r   s      r   r    zFilterAtlas.__init__  s    r   c                 8    t         j                  d      r j                  j                  S t         j                  d      r:t         j                  j                   j
                  j                         z        S t         fd j
                  D              S )Nlengthr~   c              3   F   K   | ]  }j                  |      sd   yw   Nr   .0r0   r   s     r   	<genexpr>z&FilterAtlas.__len__.<locals>.<genexpr>#       =T\\!_1=   !!hasattrr   r   r"   r~   r   rZ   sumr   s   `r   r#   zFilterAtlas.__len__  m     4<<*<<&&&4<<)t||))DKK,<,<,>>??=dkk===r   c                     	 dt         j                  j                        z  t         j                        k  }|r fd j                  j                  D        S  fd j                  D        S # t        $ r d}Y Cw xY w)N   Fc              3   @   K   | ]  }|j                   v s|  y wr   r   r   s     r   r   z'FilterAtlas.__iter__.<locals>.<genexpr>+       F!Q$++5EAF   c              3   F   K   | ]  }j                  |      s|  y wr   r   r   s     r   r   z'FilterAtlas.__iter__.<locals>.<genexpr>,       :a$,,q/:r   r"   r   r~   r   AttributeErrorr   node_ok_shorters   ` r   r'   zFilterAtlas.__iter__%  n    	$#dll&8&8"99C<LLO Ft||11FF:4;;::	  	$#O	$   8A1 1A?>A?c                 |    || j                   v r | j                  |      r| j                   |   S t        d| d      )NKey 
 not found)r   r   r^   r)   s     r   r+   zFilterAtlas.__getitem__.  s<    $++$,,s"3;;s##cU*-..r   c                 F    t        | D ci c]  }|| |   
 c}      S c c}w r   rf   rg   s     r   r5   zFilterAtlas.__str__3  rh   ri   c                 h    | j                   j                   d| j                  d| j                  dS rk   )r9   r:   r   r   r   s    r   r;   zFilterAtlas.__repr__6  s/    ..))*!DKK?"T\\<LANNr   N
r:   r=   r>   r?   r    r#   r'   r+   r5   r;   rA   r   r   r   r     s&    
>;/
5Or   r   c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	r   ad  A read-only Mapping of Mappings with filtering criteria for nodes and edges.

    It is a view into a dict-of-dict-of-dict data structure, and it selects nodes
    and edges that satisfy specific criteria defined by ``NODE_OK`` and ``EDGE_OK``,
    respectively.

    See Also
    ========
    FilterAtlas
    FilterMultiInner
    FilterMultiAdjacency
    c                 .    || _         || _        || _        y r   )r   r   EDGE_OK)r   r   r   r   s       r   r    zFilterAdjacency.__init__H  s    r   c                 8    t         j                  d      r j                  j                  S t         j                  d      r:t         j                  j                   j
                  j                         z        S t         fd j
                  D              S )Nr   r~   c              3   F   K   | ]  }j                  |      sd   ywr   r   r   s     r   r   z*FilterAdjacency.__len__.<locals>.<genexpr>T  r   r   r   r   s   `r   r#   zFilterAdjacency.__len__M  r   r   c                     	 dt         j                  j                        z  t         j                        k  }|r fd j                  j                  D        S  fd j                  D        S # t        $ r d}Y Cw xY w)Nr   Fc              3   @   K   | ]  }|j                   v s|  y wr   r   r   s     r   r   z+FilterAdjacency.__iter__.<locals>.<genexpr>\  r   r   c              3   F   K   | ]  }j                  |      s|  y wr   r   r   s     r   r   z+FilterAdjacency.__iter__.<locals>.<genexpr>]  r   r   r   r   s   ` r   r'   zFilterAdjacency.__iter__V  r   r   c                       j                   v r0 j                        r fd}t         j                      |      S t        d d      )Nc                 N    j                  |       xr j                  |       S r   r   r   )rb   rz   r   s    r   new_node_okz0FilterAdjacency.__getitem__.<locals>.new_node_okb  s"    ||C(DT\\$-DDr   r   r   r   r   r   r^   )r   rz   r   s   `` r   r+   zFilterAdjacency.__getitem___  sL    4;;4<<#5E t{{40+>>dV:.//r   c                 F    t        | D ci c]  }|| |   
 c}      S c c}w r   rf   rg   s     r   r5   zFilterAdjacency.__str__h  rh   ri   c                     | j                   j                  }| d| j                  d| j                  d| j                  dS rk   )r9   r:   r   r   r   rD   s     r   r;   zFilterAdjacency.__repr__k  s>    ~~&&qr$,,)9DLL;K1MMr   Nr   rA   r   r   r   r   :  s&    
>;05Nr   r   c                       e Zd ZdZd Zd Zy)r   aV  A read-only Mapping of Mappings with filtering criteria for nodes and edges.

    It is a view into a dict-of-dict-of-dict-of-dict data structure, and it selects nodes
    and edges that meet specific criteria defined by ``NODE_OK`` and ``EDGE_OK``.

    See Also
    ========
    FilterAtlas
    FilterAdjacency
    FilterMultiAdjacency
    c              #      K   	 dt         j                  j                        z  t         j                        k  }|r  fd j                  j                  D        }n fd j                  D        }|D ]7  }d} j                  |   D ]  } j                  ||      sd} n |du s4| 9 y # t        $ r d}Y w xY ww)Nr   Fc              3   @   K   | ]  }|j                   v s|  y wr   r   r   s     r   r   z,FilterMultiInner.__iter__.<locals>.<genexpr>  s     Jadkk9IJr   c              3   F   K   | ]  }j                  |      s|  y wr   r   r   s     r   r   z,FilterMultiInner.__iter__.<locals>.<genexpr>  s     Ba$,,q/Br   T)r"   r   r~   r   r   r   )r   r   my_nodesr0   some_keys_okr*   s   `     r   r'   zFilterMultiInner.__iter__}  s     	$#dll&8&8"99C<LLO J4<<#5#5JHB4;;BH 	A L{{1~ <<3'#'L t#	  	$#O	$s4   C8B1 A"C 	C*C1B?<C>B??Cc                       j                   v r0 j                        r fd}t         j                      |      S t        d d      )Nc                 (    j                  |       S r   )r   )r*   rb   r   s    r   r   z1FilterMultiInner.__getitem__.<locals>.new_node_ok  s    ||C--r   r   r   r   )r   rb   r   s   `` r   r+   zFilterMultiInner.__getitem__  sK    $++$,,s"3. t{{3/==cU*-..r   N)r:   r=   r>   r?   r'   r+   rA   r   r   r   r   p  s    
$/r   r   c                       e Zd ZdZd Zy)r   ak  A read-only Mapping of Mappings with filtering criteria
    for nodes and edges.

    It is a view into a dict-of-dict-of-dict-of-dict data structure,
    and it selects nodes and edges that satisfy specific criteria
    defined by ``NODE_OK`` and ``EDGE_OK``, respectively.

    See Also
    ========
    FilterAtlas
    FilterAdjacency
    FilterMultiInner
    c                       j                   v r; j                        r* fd}t         j                       j                  |      S t        d d      )Nc                 P    j                  |       xr j                  | |      S r   r   )rb   r*   rz   r   s     r   edge_okz1FilterMultiAdjacency.__getitem__.<locals>.edge_ok  s$    ||C(IT\\$S-IIr   r   r   )r   r   r   r^   )r   rz   r   s   `` r   r+   z FilterMultiAdjacency.__getitem__  sR    4;;4<<#5J $DKK$5t||WMMdV:.//r   N)r:   r=   r>   r?   r+   rA   r   r   r   r     s    0r   r   N)r?   collections.abcr   __all__r   r   r   r   r   r	   r
   r   r   r   r   rA   r   r   <module>r      s   
 $(= (=V8I 8,8 8,4L 4Ln1LW 1Lh2j 2>C. C&,O' ,O^3Ng 3Nl&/ &/R0? 0r   