
    Gd_                     L    d Z ddlZddlZddlZddlmZmZ  G d d          ZdS )z
Pajek tests
    N)edges_equalnodes_equalc                   j    e Zd Zed             Zed             Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 ZdS )	TestPajekc                    d| _         t          j                    | _        | j                            g d           | j                            g d           d| j        j        d<   t          j                    \  }| _	        t          j        |d          5 }|                    | j                             d                     d d d            d S # 1 swxY w Y   d S )Na`  *network Tralala
*vertices 4
   1 "A1"         0.0938 0.0896   ellipse x_fact 1 y_fact 1
   2 "Bb"         0.8188 0.2458   ellipse x_fact 1 y_fact 1
   3 "C"          0.3688 0.7792   ellipse x_fact 1
   4 "D2"         0.9583 0.8563   ellipse x_fact 1
*arcs
1 1 1  h2 0 w 3 c Blue s 3 a1 -130 k1 0.6 a2 -130 k2 0.6 ap 0.5 l "Bezier loop" lc BlueViolet fos 20 lr 58 lp 0.3 la 360
2 1 1  h2 0 a1 120 k1 1.3 a2 -120 k2 0.3 ap 25 l "Bezier arc" lphi 270 la 180 lr 19 lp 0.5
1 2 1  h2 0 a1 40 k1 2.8 a2 30 k2 0.8 ap 25 l "Bezier arc" lphi 90 la 0 lp 0.65
4 2 -1  h2 0 w 1 k1 -2 k2 250 ap 25 l "Circular arc" c Red lc OrangeRed
3 4 1  p Dashed h2 0 w 2 c OliveGreen ap 25 l "Straight arc" lc PineGreen
1 3 1  p Dashed h2 0 w 5 k1 -1 k2 -20 ap 25 l "Oval arc" c Brown lc Black
3 3 -1  h1 6 w 1 h2 12 k1 -2 k2 -15 ap 0.5 l "Circular loop" c Red lc OrangeRed lphi 270 la 180A1BbCD2)r	   r	   )r	   r
   )r	   r   )r
   r	   )r   r   )r   r   )r   r
   TralalanamewbzUTF-8)datanxMultiDiGraphGadd_nodes_fromadd_edges_fromgraphtempfilemkstempfnameosfdopenwriteencode)clsfdfhs      Clib/python3.11/site-packages/networkx/readwrite/tests/test_pajek.pysetup_classzTestPajek.setup_class   s    G!!444555  
	
 
	
 
	
 (F"*,,SYYr4   	/BHHSX__W--...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   .CCCc                 8    t          j        | j                   d S N)r   unlinkr   )r   s    r"   teardown_classzTestPajek.teardown_class"   s    
	#)    c                     d}t          j        |          }t          |                                          ddgk    sJ t	          |                                ddg          sJ d S )Nz&*Vertices 2
1 "1"
2 "2"
*Edges
1 2
2 112)r*   r+   )r   parse_pajeksortednodesr   edgesselfr   r   s      r"   test_parse_pajek_simplez!TestPajek.test_parse_pajek_simple&   sd    @N4  aggii  S#J....17799z:&>???????r(   c                     t          j        | j                  }t          |                                          g dk    sJ t          |                                g d          sJ d S )Nr   r   )r   r,   r   r-   r.   r   r/   )r1   r   s     r"   test_parse_pajekzTestPajek.test_parse_pajek-   s{    N49%%aggii  $;$;$;;;;;GGII  
 
 	
 	
 	
 	
 	
r(   c                    d}t          j        |          }t          |                                          h dk    sJ |j        d         ddik    sJ t	          t          |                                          h d          sJ d S )Nz@*Vertices 3
1 "one"
2 "two"
3 "three"
*Matrix
1 1 0
0 1 0
0 1 0
>   onetwothreer7   idr+   >   r6   r6   r7   r7   r7   r6   r7   r8   )r   r,   setr.   r   r/   r0   s      r"   test_parse_pajet_matzTestPajek.test_parse_pajet_mat=   s    ]N4  17799~~!8!8!88888wu~$,,,,		NNNNN
 
 	
 	
 	
 	
 	
r(   c                    t          j        | j                  }t          j        | j                  }t          |                                          t          |                                          k    sJ t          |                                |                                          sJ | j	        j
        |j
        k    sJ |D ] }|j        |         |j        |         k    sJ !d S r%   )r   r,   r   
read_pajekr   r-   r.   r   r/   r   r   )r1   r   Ginns       r"   test_read_pajekzTestPajek.test_read_pajekG   s    N49%%mDJ''aggii  F399;;$7$7777717799ciikk22222v|sy(((( 	. 	.A71:1-----	. 	.r(   c                    dd l }t          j        | j                  }|                                }t          j        ||           |                    d           t          j        |          }t          t          |          t          |                    sJ t          t          |                                          t          |                                                    sJ d S )Nr   )ior   r,   r   BytesIOwrite_pajekseekrA   r   listr   r/   )r1   rF   r   r!   Hs        r"   test_write_pajekzTestPajek.test_write_pajekP   s    			N49%%ZZ\\
q"



M"477DGG,,,,,4		??DOO<<<<<<<r(   c                    dd l }t          j                    }|                                }|                    dd           |                    dd           |                    ddd           |                    ddd           dd l}|                    d	          5 }t          j        ||           t          |          d
k    sJ 	 d d d            d S # 1 swxY w Y   d S )Nr      )int_attr   z  )
empty_attr   T)record   )
rF   r   GraphrG   add_nodeadd_edgewarningscatch_warningsrH   len)r1   rF   r   r!   rX   ws         r"   test_ignored_attributez TestPajek.test_ignored_attribute]   s'   			HJJZZ\\	

1q
!!!	

1
&&&	

1a!
$$$	

1aD
)))$$D$11 	QN1b!!!q66Q;;;;;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   $+CC!$C!c                     d}| j                             d          dd          }|d                    |          z   }t          j        |          }d S )Nz	*network

rN   )r   splitjoinr   r,   )r1   lineother_linesr   r   s        r"   test_nonamezTestPajek.test_nonamem   sN     iood++ABB/dii,,,N4  r(   c                    dd l }t          j                    }t          d          t          d          z   t          d          z   }t          d          t          d          z   t          d          z   }|                    |d|	           |                                }t          j        ||           |                    d           t          j        |          }t          t          |          t          |                    sJ t          t          |                                          t          |                                                    sJ |j        |j        k    sJ d S )
Nr   i(	  {   i  i  i  iD  	Radiohead)foo)rF   r   rU   chrrW   rG   rH   rI   rA   r   rJ   r   r/   r   )r1   rF   r   name1name2r!   rK   s          r"   test_unicodezTestPajek.test_unicodeu   s   			HJJD		CHH$s4yy0D		CII%C0	

5+5
111ZZ\\
q"



M"477DGG,,,,,4		??DOO<<<<<w!'!!!!!!r(   N)__name__
__module____qualname__classmethodr#   r'   r2   r4   r?   rD   rL   r\   rc   rk    r(   r"   r   r      s        / / [/*   [@ @ @
 
 
 
 
 
. . .	= 	= 	=   ! ! !" " " " "r(   r   )	__doc__r   r   networkxr   networkx.utilsr   r   r   rp   r(   r"   <module>rt      s     
			      3 3 3 3 3 3 3 3w" w" w" w" w" w" w" w" w" w"r(   