ó
    …~i„*  ã                   ó  • S r SSKrSSKrSSKJr  / SQrSS jrSS jrSrS r	\" \	S	5      r
S
 r\\	l         \R                  SS5      \
l         \R                  SS5      r\R                  S	S5      r\\l         SrSS jr\" \S5      rSS jr\\l         \R                  SS5      \l         \R                  SS5      r\R                  SS5      r\\l         SrS r\" \S5      rS r\\l         \R                  SS5      \l         g)zvFunctions which help end users define customize node_match and
edge_match functions to use during isomorphism checks.
é    N)Úpermutations)	Úcategorical_node_matchÚcategorical_edge_matchÚcategorical_multiedge_matchÚnumerical_node_matchÚnumerical_edge_matchÚnumerical_multiedge_matchÚgeneric_node_matchÚgeneric_edge_matchÚgeneric_multiedge_matchc                 ó¬   • [         R                  " U R                  U R                  U=(       d    U R                  U R
                  U R                  5      $ )z!Returns a deepcopy of a function.)ÚtypesÚFunctionTypeÚ__code__Ú__globals__Ú__name__Ú__defaults__Ú__closure__)ÚfÚnames     Úi/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/algorithms/isomorphism/matchhelpers.pyÚcopyfuncr      s9   € ä×ÒØ	�
‰
�A—M‘M 4×#5¨1¯:©:°q·~±~ÀqÇ}Á}óð ó    c                 óD   ^^• [        UU4S j[        X5       5       5      $ )z³Returns True if x and y are sufficiently close, elementwise.

Parameters
----------
rtol : float
    The relative error tolerance.
atol : float
    The absolute error tolerance.

c              3   óT   >#   • U  H  u  p[         R                  " XTTS 9v •  M     g7f)©Úrel_tolÚabs_tolN)ÚmathÚisclose)Ú.0ÚxiÚyiÚatolÚrtols      €€r   Ú	<genexpr>Úallclose.<locals>.<genexpr>)   s    øé € ÐXÊiÁFÀBŒt�|Š|˜B¨D¸$Ö?Êiùs   ƒ%()ÚallÚzip)ÚxÚyr%   r$   s     ``r   Úallcloser,      s   ù€ ô ÕXÌcÐRSÌiÓXÓXÐXr   aP  
Returns a comparison function for a categorical node attribute.

The value(s) of the attr(s) must be hashable and comparable via the ==
operator since they are placed into a set([]) object.  If the sets from
G1 and G2 are the same, then the constructed function returns True.

Parameters
----------
attr : string | list
    The categorical node attribute to compare, or a list of categorical
    node attributes to compare.
default : value | list
    The default value for the categorical node attribute, or a list of
    default values for the categorical node attributes.

Returns
-------
match : function
    The customized, categorical `node_match` function.

Examples
--------
>>> import networkx.algorithms.isomorphism as iso
>>> nm = iso.categorical_node_match("size", 1)
>>> nm = iso.categorical_node_match(["color", "size"], ["red", 2])

c                 ó~   ^ ^^• [        T [        5      (       a	  U U4S jnU$ [        [        T T5      5      mU4S jnU$ )Nc                 óN   >• U R                  TT5      UR                  TT5      :H  $ ©N©Úget)Údata1Údata2ÚattrÚdefaults     €€r   ÚmatchÚ%categorical_node_match.<locals>.matchM   s$   ø€ Ø—9‘9˜T 7Ó+¨u¯y©y¸¸wÓ/GÑGÐGr   c                 ó4   >^ ^• [        U U4S jT 5       5      $ )Nc              3   ón   >#   • U  H*  u  pTR                  X5      TR                  X5      :H  v •  M,     g 7fr/   r0   )r!   r4   Údr2   r3   s      €€r   r&   Ú8categorical_node_match.<locals>.match.<locals>.<genexpr>T   s*   øé € ÐUÊuÁGÀD�u—y‘y Ó)¨U¯Y©Y°tÓ-?Ö?Êuùs   ƒ25)r(   )r2   r3   Úattrss   ``€r   r6   r7   S   s   ú€ ÜÕUÉuÓUÓUÐUr   ©Ú
isinstanceÚstrÚlistr)   ©r4   r5   r6   r<   s   `` @r   r   r   J   s=   ú€ Ü�$œ×Ñö	Hð €Lô ”S˜˜wÓ'Ó(ˆõ	Vð €Lr   r   c                 ó~   ^ ^^• [        T [        5      (       a	  U U4S jnU$ [        [        T T5      5      mU4S jnU$ )Nc                 óÜ   >• U R                  5        Vs1 s H  o"R                  TT5      iM     nnUR                  5        Vs1 s H  o"R                  TT5      iM     nnX4:H  $ s  snf s  snf r/   )Úvaluesr1   )Ú	datasets1Ú	datasets2ÚdataÚvalues1Úvalues2r4   r5   s        €€r   r6   Ú*categorical_multiedge_match.<locals>.match_   se   ø€ Ø;D×;KÑ;KÔ;MÓNÒ;M°4—x‘x  gÖ.Ñ;MˆGÐNØ;D×;KÑ;KÔ;MÓNÒ;M°4—x‘x  gÖ.Ñ;MˆGÐNØÑ%Ð%ùò OùÚNs   ”A$ÁA)c                 ó,  >^^• [        5       nU R                  5        H)  m[        U4S jT 5       5      nUR                  U5        M+     [        5       nUR                  5        H)  m[        U4S jT 5       5      nUR                  U5        M+     X$:H  $ )Nc              3   óJ   >#   • U  H  u  pTR                  X5      v •  M     g 7fr/   r0   ©r!   r4   r:   r2   s      €r   r&   Ú=categorical_multiedge_match.<locals>.match.<locals>.<genexpr>j   ó   øé € ÐBºE±°˜%Ÿ)™) D×,Ð,ºEùó   ƒ #c              3   óJ   >#   • U  H  u  pTR                  X5      v •  M     g 7fr/   r0   ©r!   r4   r:   r3   s      €r   r&   rN   n   rO   rP   )ÚsetrD   ÚtupleÚadd)rE   rF   rH   r*   rI   r2   r3   r<   s        @@€r   r6   rJ   g   sz   ú€ Ü“eˆGØ"×)Ñ)Ö+�ÜÔB¹EÓBÓB�Ø—‘˜A–ñ ,ô “eˆGØ"×)Ñ)Ö+�ÜÔB¹EÓBÓB�Ø—‘˜A–ñ ,ð Ñ%Ð%r   r=   rA   s   `` @r   r   r   \   s;   ú€ Ü�$œ×Ñö	&ð& €Lô ”S˜˜wÓ'Ó(ˆõ		&ð €Lr   ÚnodeÚedger   a�  
Returns a comparison function for a numerical node attribute.

The value(s) of the attr(s) must be numerical and sortable.  If the
sorted list of values from G1 and G2 are the same within some
tolerance, then the constructed function returns True.

Parameters
----------
attr : string | list
    The numerical node attribute to compare, or a list of numerical
    node attributes to compare.
default : value | list
    The default value for the numerical node attribute, or a list of
    default values for the numerical node attributes.
rtol : float
    The relative error tolerance.
atol : float
    The absolute error tolerance.

Returns
-------
match : function
    The customized, numerical `node_match` function.

Examples
--------
>>> import networkx.algorithms.isomorphism as iso
>>> nm = iso.numerical_node_match("weight", 1.0)
>>> nm = iso.numerical_node_match(["weight", "linewidth"], [0.25, 0.5])

c                 óŠ   ^ ^^^^• [        T [        5      (       a  UU UU4S jnU$ [        [        T T5      5      mUUU4S jnU$ )Nc                 ór   >• [         R                  " U R                  TT5      UR                  TT5      TTS9$ )Nr   )r   r    r1   )r2   r3   r$   r4   r5   r%   s     €€€€r   r6   Ú#numerical_node_match.<locals>.match¢   s6   ø€ Ü—<’<Ø—	‘	˜$ Ó(Ø—	‘	˜$ Ó(ØØñ	ð r   c                 óÆ   >• T VVs/ s H  u  p#U R                  X#5      PM     nnnT VVs/ s H  u  p#UR                  X#5      PM     nnn[        XETTS9$ s  snnf s  snnf )N©r%   r$   )r1   r,   )	r2   r3   r4   r:   rH   rI   r$   r<   r%   s	         €€€r   r6   rZ   ­   sY   ø€ Ù9>Ô?º©g¨d�u—y‘y Ö)¹ˆGÑ?Ù9>Ô?º©g¨d�u—y‘y Ö)¹ˆGÑ?Ü˜G°4¸dÑCÐCùó @ùÛ?s
   ‡A¬Ar=   ©r4   r5   r%   r$   r6   r<   s   ```` @r   r   r   Ÿ   sA   ü€ Ü�$œ×Ñ÷	ð 	ð  €Lô ”S˜˜wÓ'Ó(ˆ÷	Dð
 €Lr   r   c                 óŠ   ^ ^^^^• [        T [        5      (       a  UU UU4S jnU$ [        [        T T5      5      mUUU4S jnU$ )Nc                 óª   >• [        UU4S jU R                  5        5       5      n[        UU4S jUR                  5        5       5      n[        X#TTS9$ )Nc              3   óF   >#   • U  H  oR                  TT5      v •  M     g 7fr/   r0   ©r!   rG   r4   r5   s     €€r   r&   Ú;numerical_multiedge_match.<locals>.match.<locals>.<genexpr>¼   ó   øé € ÐTÒAS¸ŸX™X d¨G×4Ð4ÒASùó   ƒ!c              3   óF   >#   • U  H  oR                  TT5      v •  M     g 7fr/   r0   ra   s     €€r   r&   rb   ½   rc   rd   r\   )ÚsortedrD   r,   )rE   rF   rH   rI   r$   r4   r5   r%   s       €€€€r   r6   Ú(numerical_multiedge_match.<locals>.match»   sD   ø€ ÜÕTÀ×AQÑAQÔASÓTÓTˆGÜÕTÀ×AQÑAQÔASÓTÓTˆGÜ˜G°4¸dÑCÐCr   c                 ó’  >^^• / nU R                  5        H)  m[        U4S jT
 5       5      nUR                  U5        M+     / nUR                  5        H)  m[        U4S jT
 5       5      nUR                  U5        M+     UR                  5         UR                  5         [	        X$5       H  u  pV[        XVTT	S9(       a  M    g   g)Nc              3   óJ   >#   • U  H  u  pTR                  X5      v •  M     g 7fr/   r0   rM   s      €r   r&   rb   Æ   rO   rP   c              3   óJ   >#   • U  H  u  pTR                  X5      v •  M     g 7fr/   r0   rR   s      €r   r&   rb   Ê   rO   rP   r\   FT)rD   rT   ÚappendÚsortr)   r,   )rE   rF   rH   r*   rI   r"   r#   r2   r3   r$   r<   r%   s          @@€€€r   r6   rg   Ã   s©   ú€ ØˆGØ"×)Ñ)Ö+�ÜÔB¹EÓBÓB�Ø—‘˜qÖ!ñ ,ð ˆGØ"×)Ñ)Ö+�ÜÔB¹EÓBÓB�Ø—‘˜qÖ!ñ ,ð �L‰LŒNØ�L‰LŒNÜ˜gÖ/‘�Ü ¨T¸×=Ñ=Ù ñ 0ð r   r=   r]   s   ```` @r   r	   r	   ¸   sB   ü€ Ü�$œ×Ñ÷	Dð 	Dð2 €Lô' ”S˜˜wÓ'Ó(ˆ÷	ð" €Lr   r	   aù  
Returns a comparison function for a generic attribute.

The value(s) of the attr(s) are compared using the specified
operators. If all the attributes are equal, then the constructed
function returns True.

Parameters
----------
attr : string | list
    The node attribute to compare, or a list of node attributes
    to compare.
default : value | list
    The default value for the node attribute, or a list of
    default values for the node attributes.
op : callable | list
    The operator to use when comparing attribute values, or a list
    of operators to use when comparing values for each attribute.

Returns
-------
match : function
    The customized, generic `node_match` function.

Examples
--------
>>> from operator import eq
>>> from math import isclose
>>> from networkx.algorithms.isomorphism import generic_node_match
>>> nm = generic_node_match("weight", 1.0, isclose)
>>> nm = generic_node_match("color", "red", eq)
>>> nm = generic_node_match(["weight", "color"], [1.0, "red"], [isclose, eq])

c                 ó„   ^ ^^^• [        T [        5      (       a
  U UU4S jnU$ [        [        T TT5      5      mU4S jnU$ )Nc                 óV   >• T" U R                  TT5      UR                  TT5      5      $ r/   r0   )r2   r3   r4   r5   Úops     €€€r   r6   Ú!generic_node_match.<locals>.match  s&   ø€ Ù�e—i‘i  gÓ.°·	±	¸$ÀÓ0HÓIÐIr   c                 óz   >• T H4  u  p#nU" U R                  X#5      UR                  X#5      5      (       a  M4    g   g)NFTr0   )r2   r3   r4   r:   Úoperatorr<   s        €r   r6   rp     s9   ø€ Û%*Ñ!�˜Ù §	¡	¨$Ó 2°E·I±I¸dÓ4F×GÓGÙ ñ &+ð r   r=   ©r4   r5   ro   r6   r<   s   ``` @r   r
   r
     s>   û€ Ü�$œ×Ñ÷	Jð €Lô ”S˜˜w¨Ó+Ó,ˆõ	ð €Lr   r   c                 ó|   ^^• [        U [        5      (       a	  U /n U/nT/m[        [        X5      5      mUU4S jnU$ )a”  Returns a comparison function for a generic attribute.

The value(s) of the attr(s) are compared using the specified
operators. If all the attributes are equal, then the constructed
function returns True. Potentially, the constructed edge_match
function can be slow since it must verify that no isomorphism
exists between the multiedges before it returns False.

Parameters
----------
attr : string | list
    The edge attribute to compare, or a list of node attributes
    to compare.
default : value | list
    The default value for the edge attribute, or a list of
    default values for the edgeattributes.
op : callable | list
    The operator to use when comparing attribute values, or a list
    of operators to use when comparing values for each attribute.

Returns
-------
match : function
    The customized, generic `edge_match` function.

Examples
--------
>>> from operator import eq
>>> from math import isclose
>>> from networkx.algorithms.isomorphism import generic_node_match
>>> nm = generic_node_match("weight", 1.0, isclose)
>>> nm = generic_node_match("color", "red", eq)
>>> nm = generic_node_match(["weight", "color"], [1.0, "red"], [isclose, eq])

c           
      ó�  >^^	• / nU R                  5        H)  m[        U4S jT
 5       5      nUR                  U5        M+     / nUR                  5        H)  m	[        U	4S jT
 5       5      nUR                  U5        M+     [        U5       H6  n[	        X%5       H$  u  pg[        [        S XgT5      5      (       a  M#    M4       g   g)Nc              3   óJ   >#   • U  H  u  pTR                  X5      v •  M     g 7fr/   r0   rM   s      €r   r&   Ú9generic_multiedge_match.<locals>.match.<locals>.<genexpr>I  ó   øé € Ð>º©W¨T�e—i‘i ×(Ð(ºùrP   c              3   óJ   >#   • U  H  u  pTR                  X5      v •  M     g 7fr/   r0   rR   s      €r   r&   rw   M  rx   rP   c                 ó   • U" X5      $ r/   © )r*   r+   Úzs      r   Ú<lambda>Ú8generic_multiedge_match.<locals>.match.<locals>.<lambda>Q  s   € ©q°¬wr   TF)rD   rT   rk   r   r)   r(   Úmap)rE   rF   rH   r*   rI   Úvals2r"   r#   r2   r3   r<   ro   s           @@€€r   r6   Ú&generic_multiedge_match.<locals>.matchF  s±   ú€ ØˆØ×%Ñ%Ö'ˆEÜÔ>¹Ó>Ó>ˆAØ�N‰N˜1Öñ (ð ˆØ×%Ñ%Ö'ˆEÜÔ>¹Ó>Ó>ˆAØ�N‰N˜1Öñ (ô " 'Ö*ˆEÜ˜gÖ-‘�Üœ3Ñ6¸ÀÓC×DÓDâñ .ñ ñ +ð r   r=   rs   s     ` @r   r   r     sC   ù€ ôN �$œ×ÑØˆvˆØ�)ˆØˆTˆÜ”�TÓ#Ó$€Eöð* €Lr   r/   )gñhãˆµøä>g:Œ0âŽyE>)Ú__doc__r   r   Ú	itertoolsr   Ú__all__r   r,   Úcategorical_docr   r   r   ÚreplaceÚtmpdocÚnumerical_docr   r   r	   Úgeneric_docr
   r   r   r{   r   r   Ú<module>rŠ      sO  ðñó Û Ý "ò
€ôôYð€ò<ñ "Ð"8Ð:RÓSÐ òð4 "1Ð Ô Ø!0×!8Ñ!8¸ÀÓ!HÐ Ô Ø	×	 Ñ	  ¨Ó	0€Ø	�‰Ð0Ð2OÓ	P€Ø&,Ð Ô #ð€ôDñ,  Ð 4Ð6LÓMÐ ôð@  -Ð Ô Ø,×4Ñ4°V¸VÓDÐ Ô Ø	×	Ñ	˜v vÓ	.€Ø	�‰Ð.Ð0KÓ	L€Ø$*Ð Ô !ð!€òHñ& Ð0Ð2FÓGÐ òBðL )Ð Ô Ø(×0Ñ0°¸Ó@Ð Õ r   