Ë
    Ìi"  ã                   ól   — d Z ddlZddlZddlZddlmZmZmZ  ej                  d«      Z
 G d„ d«      Zy)z$Unit tests for PyGraphviz interface.é    N)Úedges_equalÚgraphs_equalÚnodes_equalÚ
pygraphvizc                   ó&  — e Zd Zd„ Zd„ Zej                  j                  d ej                  «        ej                  «        ej                  «        ej                  «       f«      d„ «       Zd„ Zej                  j                  dej                  ej                  ej                  ej                  f«      d„ «       Zd„ Zd	„ Zej                  j                  dej                  ej                  f«      d
„ «       Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zej                  j7                  d¬«      d„ «       Zd„ Zd„ Zej                  j7                  d¬«      d„ «       Zd„ Z ej                  j                  d e!d«      «      d„ «       Z"d„ Z#d„ Z$d „ Z%y!)"Ú
TestAGraphc                 óp   — g d¢}|j                  |«       |j                  d«       d|j                  d<   |S )N)©ÚAÚB©r   ÚCr   )r   r   )r   ÚDÚEÚbronzeÚmetal)Úadd_edges_fromÚadd_nodeÚgraph)ÚselfÚGÚedgess      úc/var/www/html/strategist-ai/venv/lib/python3.12/site-packages/networkx/drawing/tests/test_agraph.pyÚbuild_graphzTestAGraph.build_graph   s3   € ÚLˆØ	×Ñ˜ÔØ	�
‰
�3ŒØ#ˆ�‰�ÑØˆó    c                 ó  — t        |j                  «       |j                  «       «      sJ ‚t        |j                  «       |j                  «       |j	                  «       ¬«      sJ ‚|j
                  d   |j
                  d   k(  sJ ‚y )N)Údirectedr   )r   Únodesr   r   Úis_directedr   )r   ÚG1ÚG2s      r   Úassert_equalzTestAGraph.assert_equal   sc   € Ü˜2Ÿ8™8›: r§x¡x£zÔ2Ð2Ð2Ü˜2Ÿ8™8›: r§x¡x£z¸B¿N¹NÓ<LÕMÐMÐMØ�x‰x˜Ñ  B§H¡H¨WÑ$5Ò5Ð5Ñ5r   r   c                 óÈ  — | j                  |«      }t        j                  j                  |«      }t        j                  j	                  |«      }| j                  ||«       |dz  }t        j                  j                  j                  ||«       t        j                  j                  |«      }| j                  ||«       |dz  }t        |d«      5 }t        j                  j                  j                  ||«       d d d «       t        |«      5 }t        j                  j                  |«      }d d d «       | j                  ||«       y # 1 sw Y   ŒOxY w# 1 sw Y   Œ(xY w)Nztest.dotzfh_test.dotÚw)
r   ÚnxÚ	nx_agraphÚ	to_agraphÚfrom_agraphr"   ÚdrawingÚ	write_dotÚread_dotÚopen)r   r   Útmp_pathr   ÚHÚfnameÚHinÚfhs           r   Útest_agraph_roundtrippingz$TestAGraph.test_agraph_roundtripping   s  € ð ×Ñ˜QÓˆÜ�L‰L×"Ñ" 1Ó%ˆÜ�L‰L×$Ñ$ QÓ'ˆØ×Ñ˜!˜QÔà˜:Ñ%ˆÜ
�
‰
×Ñ×&Ñ& q¨%Ô0Ü�l‰l×#Ñ# EÓ*ˆØ×Ñ˜!˜SÔ!à˜=Ñ(ˆÜ�%˜Óð 	2 Ü�J‰J× Ñ ×*Ñ*¨1¨bÔ1÷	2ô �%‹[ð 	,˜BÜ—,‘,×'Ñ'¨Ó+ˆC÷	,à×Ñ˜!˜SÕ!÷	2ð 	2ú÷	,ð 	,ús   Ã+EÄ EÅEÅE!c                 óÎ   — t        j                  d¬«      }t         j                  j                  |«      }t         j                  j	                  |«      }|j
                  dk(  sJ ‚y )NÚtest)Úname)r%   ÚGraphr&   r'   r(   r5   ©r   r   r   r.   s       r   Útest_from_agraph_namez TestAGraph.test_from_agraph_name0   sJ   € Ü�H‰H˜&Ô!ˆÜ�L‰L×"Ñ" 1Ó%ˆÜ�L‰L×$Ñ$ QÓ'ˆØ�v‰v˜ÒÐÑr   Úgraph_classc                 óÊ   — t        j                  d«      }t         j                  j                  |«      }t         j                  j	                  ||¬«      }t        ||«      sJ ‚y )Né   )Úcreate_using)r%   Ú
path_graphr&   r'   r(   Ú
isinstance)r   r9   r   r   r.   s        r   Útest_from_agraph_create_usingz(TestAGraph.test_from_agraph_create_using6   sO   € ô �M‰M˜!ÓˆÜ�L‰L×"Ñ" 1Ó%ˆÜ�L‰L×$Ñ$ Q°[Ð$ÓAˆÜ˜!˜[Ô)Ð)Ñ)r   c                 ód  — t        j                  «       }|j                  ddg«       t         j                  j	                  |«      }|j                  ddd¬«       t         j                  j                  |«      }t        |t         j                  «      sJ ‚ddddif|j                  d¬	«      v sJ ‚y )
Nr   é   Úfoo)ÚkeyÚ0Ú1rC   T©Údata)	r%   r6   Úadd_nodes_fromr&   r'   Úadd_edger(   r>   r   r7   s       r   Útest_from_agraph_named_edgesz'TestAGraph.test_from_agraph_named_edges?   s‘   € ä�H‰H‹JˆØ	×Ñ˜!˜Q˜Ô Ü�L‰L×"Ñ" 1Ó%ˆà	�
‰
�1�a˜Uˆ
Ô#ä�L‰L×$Ñ$ QÓ'ˆÜ˜!œRŸX™XÔ&Ð&Ð&Ø�S˜5 %˜.Ð)¨Q¯W©W¸$¨WÓ-?Ñ?Ð?Ñ?r   c                 óê   — t        j                  «       }|j                  dd¬«       t         j                  j	                  |«      }t        |j                  «       d   j                  «      ddik(  sJ ‚y )NrA   Úred©Úcolorr   rN   )r%   r6   r   r&   r'   Údictr   Úattr©r   r   r   s      r   Útest_to_agraph_with_nodedataz'TestAGraph.test_to_agraph_with_nodedataK   sY   € Ü�H‰H‹JˆØ	�
‰
�1˜Eˆ
Ô"Ü�L‰L×"Ñ" 1Ó%ˆÜ�A—G‘G“I˜a‘L×%Ñ%Ó&¨7°EÐ*:Ò:Ð:Ñ:r   c                 óø   —  |«       }|j                  ddg«       |j                  ddd¬«       t        j                  j	                  |«      }t        |j                  «       d   j                  «      ddik(  sJ ‚y )Nr   rA   ÚyellowrM   rN   )rH   rI   r%   r&   r'   rO   r   rP   )r   r9   r   r   s       r   Útest_to_agraph_with_edgedataz'TestAGraph.test_to_agraph_with_edgedataQ   si   € á‹MˆØ	×Ñ˜!˜Q˜Ô Ø	�
‰
�1�a˜xˆ
Ô(Ü�L‰L×"Ñ" 1Ó%ˆÜ�A—G‘G“I˜a‘L×%Ñ%Ó&¨7°HÐ*=Ò=Ð=Ñ=r   c                 ó$  — t        j                  d«      }t        |dz  «      }t         j                  j	                  ||d¬«      \  }}||k(  sJ ‚t        |d«      5 }|j                  «       }d d d «       t        «      dkD  sJ ‚y # 1 sw Y   ŒxY w)Nr;   z	graph.pngF)ÚpathÚshowÚrbr   )r%   Úcomplete_graphÚstrr&   Úview_pygraphvizr,   ÚreadÚlen)r   r-   r   Ú
input_pathÚout_pathr   r1   rG   s           r   Útest_view_pygraphviz_pathz$TestAGraph.test_view_pygraphviz_pathY   sŠ   € Ü×Ñ˜aÓ ˆÜ˜ KÑ/Ó0ˆ
Ü—l‘l×2Ñ2°1¸:ÈEÐ2ÓR‰ˆ�!Ø˜:Ò%Ð%Ð%ä�*˜dÓ#ð 	 rØ—7‘7“9ˆD÷	ä�4‹y˜1Š}Ð‰}÷	ð 	ús   ÁBÂBc                 óŒ   — t        j                  d«      }t         j                  j                  |dd¬«      \  }}|dd  dk(  sJ ‚y )Nr;   rA   F)ÚsuffixrX   iúÿÿÿz_1.png)r%   rZ   r&   r\   )r   r-   r   rW   r   s        r   Ú test_view_pygraphviz_file_suffixz+TestAGraph.test_view_pygraphviz_file_suffixc   sE   € Ü×Ñ˜aÓ ˆÜ—,‘,×.Ñ.¨q¸ÀÐ.ÓG‰ˆˆaØ�B�Cˆy˜HÒ$Ð$Ñ$r   c                 ó  — t        j                  «       }t        j                  t         j                  t         j
                  j                  |«       t        j                  dd«      }t         j
                  j                  |d¬«       y )Né   é   F©rX   )r%   r6   ÚpytestÚraisesÚNetworkXExceptionr&   r\   Úbarbell_graph)r   r   s     r   Útest_view_pygraphvizzTestAGraph.test_view_pygraphvizh   sV   € Ü�H‰H‹JˆÜ�‰”b×*Ñ*¬B¯L©L×,HÑ,HÈ!ÔLÜ×Ñ˜Q Ó"ˆÜ
�‰×$Ñ$ Q¨UÐ$Õ3r   c                 ó  — t        j                  «       }|j                  ddd¬«       |j                  ddd¬«       t         j                  j	                  |dd¬	«      \  }}|j                  «       D ]  }|j                  d   d
v rŒJ ‚ y )NrA   é   é   )Úweightr;   é   rq   F©Ú	edgelabelrX   )Ú7Ú8)r%   r6   rI   r&   r\   r   rP   )r   r   rW   r   Úedges        r   Útest_view_pygraphviz_edgelabelz)TestAGraph.test_view_pygraphviz_edgelabeln   s|   € Ü�H‰H‹JˆØ	�
‰
�1�a ˆ
Ô"Ø	�
‰
�1�a ˆ
Ô"Ü—,‘,×.Ñ.¨q¸HÈ5Ð.ÓQ‰ˆˆaØ—G‘G“Iò 	5ˆDØ—9‘9˜XÑ&¨*Ò4Ð4Ð4ñ	5r   c                 óÐ   — t        j                  d«      }d„ }t         j                  j                  ||d¬«      \  }}|j	                  «       D ]  }|j
                  d   dk(  rŒJ ‚ y )Nr;   c                  ó   — y)NrB   © rF   s    r   Ú	foo_labelzETestAGraph.test_view_pygraphviz_callable_edgelabel.<locals>.foo_labely   s   € Ør   Frs   ÚlabelrB   )r%   rZ   r&   r\   r   rP   )r   r   r|   rW   r   rw   s         r   Ú'test_view_pygraphviz_callable_edgelabelz2TestAGraph.test_view_pygraphviz_callable_edgelabelv   sd   € Ü×Ñ˜aÓ ˆò	ô —,‘,×.Ñ.¨q¸IÈEÐ.ÓR‰ˆˆaØ—G‘G“Iò 	/ˆDØ—9‘9˜WÑ%¨Ó.Ð.Ð.ñ	/r   c                 óZ  — t        j                  «       }|j                  dddd¬«       |j                  dddd¬«       t         j                  j	                  |dd¬«      \  }}|j                  «       }t        |«      d	k(  sJ ‚|D ]#  }|j                  d
   j                  «       dv rŒ#J ‚ y )Nr   rA   Ú	left_fork)rC   r5   Ú
right_forkr5   Frs   ro   r}   )r€   r�   )	r%   Ú
MultiGraphrI   r&   r\   r   r^   rP   Ústrip)r   r   rW   r   r   rw   s         r   Ú*test_view_pygraphviz_multigraph_edgelabelsz5TestAGraph.test_view_pygraphviz_multigraph_edgelabels€   s¡   € Ü�M‰M‹OˆØ	�
‰
�1�a˜Q [ˆ
Ô1Ø	�
‰
�1�a˜Q \ˆ
Ô2Ü—,‘,×.Ñ.¨q¸FÈÐ.ÓO‰ˆˆaØ—‘“	ˆÜ�5‹z˜QŠÐˆØò 	MˆDØ—9‘9˜WÑ%×+Ñ+Ó-Ð1LÒLÐLÐLñ	Mr   c                 óø   — t        j                  «       }| j                  |«      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   t         j
                  j                  |«      }y )NÚkeywordr   Únr
   ÚuÚv)r%   r6   r   r   r   r&   r'   rQ   s      r   Ú!test_graph_with_reserved_keywordsz,TestAGraph.test_graph_with_reserved_keywordsŠ   sk   € ô �H‰H‹JˆØ×Ñ˜QÓˆØ%ˆ�‰�‰�SÑØ#,ˆ�‰�
Ñ˜CÑ Ø#,ˆ�‰�
Ñ˜CÑ Ü�L‰L×"Ñ" 1Ó%‰r   c                 ó˜   — t        j                  d«      }t         j                  j                  |d¬«      \  }}|j                  i k(  sJ ‚y )Nro   Frh   )r%   rZ   r&   r\   r   ©r   r   rW   r   s       r   Ú,test_view_pygraphviz_no_added_attrs_to_inputz7TestAGraph.test_view_pygraphviz_no_added_attrs_to_input•   s?   € Ü×Ñ˜aÓ ˆÜ—,‘,×.Ñ.¨q°uÐ.Ó=‰ˆˆaØ�w‰w˜"Š}Ð‰}r   zknown bug in clean_attrs)Úreasonc                 óê   — t        j                  d«      }ddi|j                  d<   ddi|j                  d<   t         j                  j	                  |d¬	«      \  }}|j                  ddiddid
œk(  sJ ‚y )Nro   Úwidthú0.80ÚnodeÚfontsizeÚ14rw   Frh   )r’   rw   )r%   rZ   r   r&   r\   rŒ   s       r   Ú2test_view_pygraphviz_leaves_input_graph_unmodifiedz=TestAGraph.test_view_pygraphviz_leaves_input_graph_unmodifiedš   st   € ä×Ñ˜aÓ ˆà" FÐ+ˆ�‰�‰Ø% tÐ,ˆ�‰�‰Ü—,‘,×.Ñ.¨q°uÐ.Ó=‰ˆˆaØ�w‰w G¨VÐ#4¸zÈ4Ð>PÑQÒQÐQÑQr   c                 ó.  — t        j                  d«      }ddi|j                  d<   ddi|j                  d<   t         j                  j	                  |d¬	«      \  }}t        |j                  «      d   dk(  sJ ‚t        |j                  «      d   dk(  sJ ‚y )
Nro   r�   r‘   r’   r“   r”   rw   Frh   )r%   rZ   r   r&   r\   rO   Ú	node_attrÚ	edge_attrrŒ   s       r   Útest_graph_with_AGraph_attrsz'TestAGraph.test_graph_with_AGraph_attrs£   s‹   € Ü×Ñ˜aÓ ˆà" FÐ+ˆ�‰�‰Ø% tÐ,ˆ�‰�‰Ü—,‘,×.Ñ.¨q°uÐ.Ó=‰ˆˆaä�A—K‘KÓ  Ñ)¨VÒ3Ð3Ð3Ü�A—K‘KÓ  Ñ,°Ò4Ð4Ñ4r   c                 óx  — t        j                  «       }t         j                  j                  |«      }t         j                  j	                  |«      }t        ||«      sJ ‚t         j                  j                  |«      }t         j                  j	                  |«      }t        ||«      sJ ‚t        ||«      sJ ‚y ©N)r%   r6   r&   r'   r(   r   )r   r   r   r.   ÚAAÚHHs         r   Útest_round_trip_empty_graphz&TestAGraph.test_round_trip_empty_graph­   s�   € Ü�H‰H‹JˆÜ�L‰L×"Ñ" 1Ó%ˆÜ�L‰L×$Ñ$ QÓ'ˆÜ˜A˜qÔ!Ð!Ð!Ü�\‰\×#Ñ# AÓ&ˆÜ�\‰\×%Ñ% bÓ)ˆÜ˜A˜rÔ"Ð"Ð"Ü˜A˜rÔ"Ð"Ñ"r   z-integer->string node conversion in round tripc                 óÆ   — t        j                  d«      }t         j                  j                  |«      }t         j                  j	                  |«      }t        ||«      sJ ‚y )Nr;   )r%   rZ   r&   r'   r(   r   r7   s       r   Útest_round_trip_integer_nodesz(TestAGraph.test_round_trip_integer_nodes·   sJ   € ä×Ñ˜aÓ ˆÜ�L‰L×"Ñ" 1Ó%ˆÜ�L‰L×$Ñ$ QÓ'ˆÜ˜A˜qÔ!Ð!Ñ!r   c                 óÔ   — | j                  t        j                  «       «      }t        j                  j	                  |«      }t        j                  j                  |«      }||k(  sJ ‚y r›   )r   r%   r6   r&   Úgraphviz_layoutÚpygraphviz_layout)r   r   Úpos_graphvizÚpos_pygraphvizs       r   Útest_graphviz_aliaszTestAGraph.test_graphviz_alias¾   sN   € Ø×ÑœRŸX™X›ZÓ(ˆÜ—|‘|×3Ñ3°AÓ6ˆÜŸ™×7Ñ7¸Ó:ˆØ˜~Ò-Ð-Ñ-r   Úrooté   c                 ó|  — t        j                  d«      }t         j                  j                  |«      }t         j                  j	                  |d|¬«      }|j                  d|› �d¬«       t        d„ t        |j                  d«      j                  «      d   j                  d	«      D «       «      }|d
   |k(  sJ ‚y )Nr¨   Úcirco)Úprogr§   z-Groot=)Úargsr«   c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr›   )Úfloat)Ú.0r‰   s     r   ú	<genexpr>z9TestAGraph.test_pygraphviz_layout_root.<locals>.<genexpr>Î   s   è ø€ ÒV A”u˜Q—xÑVùs   ‚rE   Úposú,rA   )r%   rZ   r&   r'   r£   ÚlayoutÚtuplerO   Úget_noderP   Úsplit)r   r§   r   r   Úpygv_layoutÚa1_poss         r   Útest_pygraphviz_layout_rootz&TestAGraph.test_pygraphviz_layout_rootÄ   s    € ô ×Ñ˜aÓ ˆÜ�L‰L×"Ñ" 1Ó%ˆä—l‘l×4Ñ4°Q¸WÈ4Ð4ÓPˆà	�‰˜ ˜vÐ&¨WˆÔ5äÑV¬¨a¯j©j¸«o×.BÑ.BÓ)CÀEÑ)J×)PÑ)PÐQTÓ)UÔVÓVˆØ˜1‰~ Ò'Ð'Ñ'r   c                 ó&  — t        j                  «       }| j                  |«      }d|j                  d<   t         j                  j                  |d¬«      }t        |j                  «       «      }t        |«      dk(  sJ ‚t        |d   «      dk(  sJ ‚y )Nro   ÚdimenÚneato©r«   r¨   r   ©	r%   r6   r   r   r&   r£   ÚlistÚvaluesr^   ©r   r   r±   s      r   Útest_2d_layoutzTestAGraph.test_2d_layoutÑ   óz   € Ü�H‰H‹JˆØ×Ñ˜QÓˆØˆ�‰�ÑÜ�l‰l×,Ñ,¨Q°WÐ,Ó=ˆÜ�3—:‘:“<Ó ˆÜ�3‹x˜1Š}Ðˆ}Ü�3�q‘6‹{˜aÒÐÑr   c                 ó&  — t        j                  «       }| j                  |«      }d|j                  d<   t         j                  j                  |d¬«      }t        |j                  «       «      }t        |«      dk(  sJ ‚t        |d   «      dk(  sJ ‚y )Nr;   r»   r¼   r½   r¨   r   r¾   rÁ   s      r   Útest_3d_layoutzTestAGraph.test_3d_layoutÚ   rÃ   r   c                 óL  — t        j                  «       }|j                  dd¬«       |j                  dd¬«       t         j                  j	                  |«      }t        j                  d¬«      5 }|j                  «        d d d «       t        «      dk(  sJ ‚y # 1 sw Y   ŒxY w)Nr   )r   r   )r±   rA   )rA   rA   T)Úrecord)	r%   r6   r   r&   r'   ÚwarningsÚcatch_warningsr³   r^   )r   r   r   rÇ   s       r   Útest_no_warnings_raisedz"TestAGraph.test_no_warnings_raisedã   sƒ   € ô �H‰H‹JˆØ	�
‰
�1˜&ˆ
Ô!Ø	�
‰
�1˜&ˆ
Ô!Ü�L‰L×"Ñ" 1Ó%ˆÜ×$Ñ$¨DÔ1ð 	°VØ�H‰HŒJ÷	ä�6‹{˜aÒÐÑ÷	ð 	ús   Á0BÂB#N)&Ú__name__Ú
__module__Ú__qualname__r   r"   ri   ÚmarkÚparametrizer%   r6   ÚDiGraphr‚   ÚMultiDiGraphr2   r8   r?   rJ   rR   rU   ra   rd   rm   rx   r~   r„   rŠ   r�   Úxfailr•   r™   rž   r    r¦   Úranger¹   rÂ   rÅ   rÊ   r{   r   r   r   r      s£  „ òò6ð
 ‡[�[×ÑØˆhˆb�h‰h‹j˜*˜"Ÿ*™*›,¨¨¯©«¸¸¿¹Ó9JÐKóñ"óð"ò& ð ‡[�[×ÑØ˜Ÿ™ "§*¡*¨b¯m©m¸R¿_¹_ÐMóñ*óð*ò
@ò;ð ‡[�[×Ñ˜]¨R¯X©X°r·}±}Ð,EÓFñ>ó Gð>òò%ò
4ò5ò/òMò	&òð
 ‡[�[×ÑÐ8ÐÓ9ñRó :ðRò5ò#ð ‡[�[×ÑÐMÐÓNñ"ó Oð"ò.ð ‡[�[×Ñ˜V¡U¨1£XÓ.ñ
(ó /ð
(ò ò ó
 r   r   )Ú__doc__rÈ   ri   Únetworkxr%   Únetworkx.utilsr   r   r   Úimportorskipr   r   r{   r   r   ú<module>rØ      s5   ðÙ *ã ã ã ß AÑ Aà ˆV× Ñ  Ó.€
÷` ò ` r   