
    fi3                     R   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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.
    )Mapping)	AtlasViewAdjacencyViewMultiAdjacencyView
UnionAtlasUnionAdjacencyUnionMultiInnerUnionMultiAdjacencyFilterAtlasFilterAdjacencyFilterMultiInnerFilterMultiAdjacencyc                   L    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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                     d| j         iS Nr   r   selfs    r/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/networkx/classes/coreviews.py__getstate__zAtlasView.__getstate__&   s    $+&&    c                      |d         | _         d S r   r   r   states     r   __setstate__zAtlasView.__setstate__)   s    Hor   c                     || _         d S 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    DK   r   c                     | j         |         S r   r   r   keys     r   __getitem__zAtlasView.__getitem__5   s    {3r   c                 *      fd j         D             S )Nc                 F    i | ]}||                                          S  copy.0nr   s     r   
<dictcomp>z"AtlasView.copy.<locals>.<dictcomp>9   '    777a47<<>>777r   r   r   s   `r   r0   zAtlasView.copy8       77774;7777r   c                 *    t          | j                  S r   )strr   r   s    r   __str__zAtlasView.__str__;   r$   r   c                 0    | j         j         d| j        dS )N())	__class____name__r   r   s    r   __repr__zAtlasView.__repr__>   s     .)<<DK<<<<r   Nr>   
__module____qualname____doc__	__slots__r   r   r    r#   r'   r+   r0   r9   r?   r.   r   r   r   r      s        
 
 I' ' '& & &       ! ! !     8 8 8     = = = = =r   r   c                   "    e Zd ZdZdZd Z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                 6    t          | j        |                   S r   )r   r   r   names     r   r+   zAdjacencyView.__getitem__Q   s    T*+++r   c                 *      fd j         D             S )Nc                 F    i | ]}||                                          S r.   r/   r1   s     r   r4   z&AdjacencyView.copy.<locals>.<dictcomp>U   r5   r   r   r   s   `r   r0   zAdjacencyView.copyT   r6   r   Nr>   rA   rB   rC   rD   r+   r0   r.   r   r   r   r   B   sC        
 
 I, , ,8 8 8 8 8r   r   c                   "    e Zd ZdZdZd Zd ZdS )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                 6    t          | j        |                   S r   )r   r   rG   s     r   r+   zMultiAdjacencyView.__getitem__g   s    T[.///r   c                 *      fd j         D             S )Nc                 F    i | ]}||                                          S r.   r/   r1   s     r   r4   z+MultiAdjacencyView.copy.<locals>.<dictcomp>k   r5   r   r   r   s   `r   r0   zMultiAdjacencyView.copyj   r6   r   NrK   r.   r   r   r   r   X   sC        
 
 I0 0 08 8 8 8 8r   r   c                   L    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S )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                      | j         | j        dS NrQ   rQ   r   s    r   r   zUnionAtlas.__getstate__~       dj999r   c                 :    |d         | _         |d         | _        d S NrR   rS   rQ   r   s     r   r   zUnionAtlas.__setstate__       7^
7^


r   c                 "    || _         || _        d S r   rQ   r   succpreds      r   r    zUnionAtlas.__init__   s    



r   c                     t          | j                                        | j                                        z            S r   )r"   rR   keysrS   r   s    r   r#   zUnionAtlas.__len__   s-    4:??$$tz'8'88999r   c                     t          t          | j                                                  t          | j                                                  z            S r   )r&   setrR   r_   rS   r   s    r   r'   zUnionAtlas.__iter__   s=    C
))**S1B1B-C-CCDDDr   c                 X    	 | j         |         S # t          $ r | j        |         cY S w xY wr   )rR   KeyErrorrS   r)   s     r   r+   zUnionAtlas.__getitem__   s@    	#:c?" 	# 	# 	#:c?"""	#s    ))c                     d | j                                         D             }| j                                        D ]<\  }}||v r||                             |           %|                                ||<   =|S )Nc                 >    i | ]\  }}||                                 S r.   r/   )r2   nbrdds      r   r4   z#UnionAtlas.copy.<locals>.<dictcomp>   s&    CCCWS"#rwwyyCCCr   )rR   itemsrS   updater0   )r   resultrf   rg   s       r   r0   zUnionAtlas.copy   s    CC
0@0@0B0BCCCz'')) 	( 	(GCf}}s""2&&&& ggiisr   c                 :     t           fd D                       S )Nc                 "    i | ]}||         S r.   r.   r2   rf   r   s     r   r4   z&UnionAtlas.__str__.<locals>.<dictcomp>       333sCc333r   r8   r   s   `r   r9   zUnionAtlas.__str__   &    3333d333444r   c                 @    | j         j         d| j        d| j        dS Nr;   z, r<   r=   r>   rR   rS   r   s    r   r?   zUnionAtlas.__repr__   *    .)KKDJKKDJKKKKr   Nr@   r.   r   r   r   r   n   s          #I: : :$ $ $  : : :E E E# # #  5 5 5L L L L Lr   r   c                   L    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S )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
    rQ   c                      | j         | j        dS rU   rQ   r   s    r   r   zUnionAdjacency.__getstate__   rV   r   c                 :    |d         | _         |d         | _        d S rX   rQ   r   s     r   r   zUnionAdjacency.__setstate__   rY   r   c                     t          t          |                                          t          |                                          z            dk    sJ || _        || _        d S )Nr   )r"   ra   r_   rR   rS   r[   s      r   r    zUnionAdjacency.__init__   sR    3tyy{{##c$))++&6&66771<<<<



r   c                 *    t          | j                  S r   )r"   rR   r   s    r   r#   zUnionAdjacency.__len__   s    4:r   c                 *    t          | j                  S r   )r&   rR   r   s    r   r'   zUnionAdjacency.__iter__   s    DJr   c                 N    t          | j        |         | j        |                   S r   )r   rR   rS   )r   rf   s     r   r+   zUnionAdjacency.__getitem__   s    $*S/4:c?;;;r   c                 *      fd j         D             S )Nc                 F    i | ]}||                                          S r.   r/   r1   s     r   r4   z'UnionAdjacency.copy.<locals>.<dictcomp>   s'    666a47<<>>666r   )rR   r   s   `r   r0   zUnionAdjacency.copy   s    66664:6666r   c                 :     t           fd D                       S )Nc                 "    i | ]}||         S r.   r.   rm   s     r   r4   z*UnionAdjacency.__str__.<locals>.<dictcomp>   rn   r   ro   r   s   `r   r9   zUnionAdjacency.__str__   rp   r   c                 @    | j         j         d| j        d| j        dS rr   rs   r   s    r   r?   zUnionAdjacency.__repr__   rt   r   Nr@   r.   r   r   r   r      s         " #I: : :$ $ $         < < <7 7 75 5 5L L L L Lr   r   c                   "    e Zd ZdZdZd Zd ZdS )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                     || j         v }|| j        v }|rC|r&t          | j         |         | j        |                   S t          | j         |         i           S t          i | j        |                   S r   )rR   rS   r   )r   nodein_succin_preds       r   r+   zUnionMultiInner.__getitem__   sw    $*$$*$ 	4 F!$*T"2DJt4DEEEdj.333"dj.///r   c                      t           j                                                  t           j                                                  z  } fd|D             S )Nc                 F    i | ]}||                                          S r.   r/   r1   s     r   r4   z(UnionMultiInner.copy.<locals>.<dictcomp>   s'    111a47<<>>111r   )ra   rR   r_   rS   )r   nodess   ` r   r0   zUnionMultiInner.copy   sO    DJOO%%&&TZ__->->)?)??111151111r   NrK   r.   r   r   r	   r	      sC          I0 0 02 2 2 2 2r   r	   c                       e Zd ZdZdZ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                 N    t          | j        |         | j        |                   S r   )r	   rR   rS   )r   r   s     r   r+   zUnionMultiAdjacency.__getitem__  s     tz$/D1ABBBr   N)r>   rA   rB   rC   rD   r+   r.   r   r   r
   r
      s9        
 
 IC C C C Cr   r
   c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	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                 "    || _         || _        d S r   )r   NODE_OK)r   r   r   s      r   r    zFilterAtlas.__init__  s    r   c                     t           j        d          r j        j        S t           j        d          r3t           j        j         j                                        z            S t           fd j        D                       S )Nlengthr   c              3   F   K   | ]}                     |          d V  dS    Nr   r1   s     r   	<genexpr>z&FilterAtlas.__len__.<locals>.<genexpr>#  2      ==T\\!__=1======r   hasattrr   r   r"   r   r   r_   sumr   s   `r   r#   zFilterAtlas.__len__       4<** 	'<&&4<)) 	@t|)DK,<,<,>,>>???====dk======r   c                      	 dt           j        j                  z  t           j                  k     }n# t          $ r d}Y nw xY w|r fd j        j        D             S  fd j        D             S )N   Fc              3   .   K   | ]}|j         v |V  d S r   r   r1   s     r   r   z'FilterAtlas.__iter__.<locals>.<genexpr>+  /      FF!Q$+5E5EA5E5E5E5EFFr   c              3   F   K   | ]}                     |          |V  d S r   r   r1   s     r   r   z'FilterAtlas.__iter__.<locals>.<genexpr>,  2      ::a$,,q//:::::::r   r"   r   r   r   AttributeErrorr   node_ok_shorters   ` r   r'   zFilterAtlas.__iter__%      	$#dl&8"9"99C<L<LLOO 	$ 	$ 	$#OOO	$ 	GFFFFt|1FFFF::::4;::::   26 AAc                 ~    || j         v r"|                     |          r| j         |         S t          d| d          )NKey 
 not found)r   r   rc   r)   s     r   r+   zFilterAtlas.__getitem__.  sG    $+$,,s"3"3;s##-c---...r   c                 :     t           fd D                       S )Nc                 "    i | ]}||         S r.   r.   rm   s     r   r4   z'FilterAtlas.__str__.<locals>.<dictcomp>4  rn   r   ro   r   s   `r   r9   zFilterAtlas.__str__3  rp   r   c                 @    | j         j         d| j        d| j        dS rr   )r=   r>   r   r   r   s    r   r?   zFilterAtlas.__repr__6  s*    .)NNDKNNT\NNNNr   N
r>   rA   rB   rC   r    r#   r'   r+   r9   r?   r.   r   r   r   r     s}        
 
  > > >; ; ;/ / /
5 5 5O O O O Or   r   c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	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                 0    || _         || _        || _        d S r   )r   r   EDGE_OK)r   r   r   r   s       r   r    zFilterAdjacency.__init__H  s    r   c                     t           j        d          r j        j        S t           j        d          r3t           j        j         j                                        z            S t           fd j        D                       S )Nr   r   c              3   F   K   | ]}                     |          d V  dS r   r   r1   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     }n# t          $ r d}Y nw xY w|r fd j        j        D             S  fd j        D             S )Nr   Fc              3   .   K   | ]}|j         v |V  d S r   r   r1   s     r   r   z+FilterAdjacency.__iter__.<locals>.<genexpr>\  r   r   c              3   F   K   | ]}                     |          |V  d S r   r   r1   s     r   r   z+FilterAdjacency.__iter__.<locals>.<genexpr>]  r   r   r   r   s   ` r   r'   zFilterAdjacency.__iter__V  r   r   c                       j         v r6                               r! fd}t           j                  |          S t          d d          )Nc                 Z                         |           o                    |           S r   r   r   )rf   r   r   s    r   new_node_okz0FilterAdjacency.__getitem__.<locals>.new_node_okb  s(    ||C((DT\\$-D-DDr   r   r   )r   r   r   rc   )r   r   r   s   `` r   r+   zFilterAdjacency.__getitem___  sy    4;4<<#5#5E E E E E E t{40+>>>.d...///r   c                 :     t           fd D                       S )Nc                 "    i | ]}||         S r.   r.   rm   s     r   r4   z+FilterAdjacency.__str__.<locals>.<dictcomp>i  rn   r   ro   r   s   `r   r9   zFilterAdjacency.__str__h  rp   r   c                 T    | j         j        }| d| j        d| j        d| j        dS rr   )r=   r>   r   r   r   rG   s     r   r?   zFilterAdjacency.__repr__k  s9    ~&MMMM$,MMDLMMMMr   Nr   r.   r   r   r   r   :  s}           
> > >; ; ;0 0 05 5 5N N N N Nr   r   c                       e Zd ZdZd Zd ZdS )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              #   f   K   	 dt           j        j                  z  t           j                  k     }n# t          $ r d}Y nw xY w|r fd j        j        D             }n fd j        D             }|D ]6}d} j        |         D ]}                     ||          rd} n|du r|V  7d S )Nr   Fc              3   .   K   | ]}|j         v |V  d S r   r   r1   s     r   r   z,FilterMultiInner.__iter__.<locals>.<genexpr>  s/      JJadk9I9I9I9I9I9IJJr   c              3   F   K   | ]}                     |          |V  d S r   r   r1   s     r   r   z,FilterMultiInner.__iter__.<locals>.<genexpr>  s2      BBa$,,q//BBBBBBBr   T)r"   r   r   r   r   r   )r   r   my_nodesr3   some_keys_okr*   s   `     r   r'   zFilterMultiInner.__iter__}  s     	$#dl&8"9"99C<L<LLOO 	$ 	$ 	$#OOO	$ 	CJJJJ4<#5JJJHHBBBB4;BBBH 	 	A L{1~  <<3'' #'LE t##	 	s   28 AAc                       j         v r]                               rHt           fd j                  D                       r! fd}t           j                  |          S t	          d d          )Nc              3   D   K   | ]}                     |          V  d S r   r   )r2   r*   rf   r   s     r   r   z/FilterMultiInner.__getitem__.<locals>.<genexpr>  s1      GGsDLLc**GGGGGGr   c                 0                         |           S r   r   )r*   rf   r   s    r   r   z1FilterMultiInner.__getitem__.<locals>.new_node_ok  s    ||C---r   r   r   )r   r   anyr   rc   )r   rf   r   s   `` r   r+   zFilterMultiInner.__getitem__  s    4;S!! GGGGGdk#6FGGGGG 
. . . . . . t{3/===-c---...r   N)r>   rA   rB   rC   r'   r+   r.   r   r   r   r   p  s<        
 
  $/ / / / /r   r   c                       e Zd ZdZd ZdS )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<                               r' fd}t           j                   j        |          S t          d d          )Nc                 \                         |           o                    | |          S r   r   )rf   r*   r   r   s     r   edge_okz1FilterMultiAdjacency.__getitem__.<locals>.edge_ok  s*    ||C((IT\\$S-I-IIr   r   r   )r   r   r   rc   )r   r   r   s   `` r   r+   z FilterMultiAdjacency.__getitem__  s}    4;4<<#5#5J J J J J J $DK$5t|WMMM.d...///r   N)r>   rA   rB   rC   r+   r.   r   r   r   r     s-         0 0 0 0 0r   r   N)rC   collections.abcr   __all__r   r   r   r   r   r	   r
   r   r   r   r   r.   r   r   <module>r      s:   
 $ # # # # #  (= (= (= (= (= (= (= (=V8 8 8 8 8I 8 8 8,8 8 8 8 8 8 8 8,4L 4L 4L 4L 4L 4L 4L 4Ln1L 1L 1L 1L 1LW 1L 1L 1Lh2 2 2 2 2j 2 2 2>C C C C C. C C C&,O ,O ,O ,O ,O' ,O ,O ,O^3N 3N 3N 3N 3Ng 3N 3N 3Nl*/ */ */ */ */ */ */ */Z0 0 0 0 0? 0 0 0 0 0r   