
    VhO{                         d dl Z d dlZd dl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 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 Zd Zd Zd Z d Z!d  Z"d! Z#y)"    Nc                  d   t        j                         } t        j                  t        d      5  t        j
                  | d       d d d        t        j                  t        d      5  t        j                  | d       d d d        t        j                  t        d      5  t        j
                  | d       d d d        t        j                  t        d      5  t        j                  | d       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ]xY w# 1 sw Y   y xY w)Nz7The WL algorithm requires that `iterations` be positive)match
iterationsr   )nxempty_graphpytestraises
ValueErrorweisfeiler_lehman_graph_hash!weisfeiler_lehman_subgraph_hashes)G1s    \/home/dcms/DCMS/lib/python3.12/site-packages/networkx/algorithms/tests/test_graph_hashing.pytest_positive_itersr   
   s   		B	G
 ; 	''r:	;
 
G
 @ 	,,RB?	@
 
G
 : 	''q9	:
 
G
 ? 	,,RA>	? ?; ;
@ @
: :
? ?s/   D+D&D!D&DDD#&D/c                     t        j                         } t        j                         }t        j                  |       }t        j                  |      }t        j                  |d      }t        j                  |d      }t        j                  |dd      }t        j                  |d      }||k(  sJ ||k(  sJ ||k(  sJ ||k(  sJ ||k(  sJ y)	zD
    empty graphs should give hashes regardless of other params
    
edge_attr1	edge_attr
node_attr1	node_attrr   r   
   r   N)r   r	   r   )r   G2h1h2h3h4h5h6s           r   test_empty_graph_hashr"   %   s     
	B		B		(	(	,B		(	(	,B		(	(|	DB		(	(|	DB		(	(
ll
B 
	(	(	;B8O88O88O88O88O8    c                      d} t        |       D ]e  }t        j                  d| z   d|z         }t        j                  |      }t        j                  |      }t        j                  |      }||k7  reJ  y)z
    A directed graph with no bi-directional edges should yield different a graph hash
    to the same graph taken as undirected if there are no hash collisions.
    r   d   seedN)ranger   gn_graphto_undirectedr   )ri
G_directedG_undirected
h_directedh_undirecteds         r   test_directedr1   <   sr    
 	A1X *[[acAg6
''
344Z@
66|D\)))*r#   c            
      ^   t        j                  dt         j                        } t        j                  | | j	                         D ci c]  }|t        |       c}d       | j                         }t        j                  | d      }t        j                  |d      }||k7  sJ yc c}w )z
    A directed graph with no bi-directional edges should yield different a graph hash
    to the same graph taken with edge directions reversed if there are no hash
    collisions. Here we test a cycle graph which is the minimal counterexample
       create_usinglabelnamer   N)r   cycle_graphDiGraphset_node_attributesnodesstrreverser   Gn
G_reversedh
h_reverseds        r   test_reversedrE   L   s     	qrzz2A1!'')<Qq#a&y<7KJ
''W=A00wOJ
?? =   B*
c            
      T   d\  } }d|z  }t        d|dz         D ]  }t        j                  | ||z  d|z         }t        j                  ||j	                         D ci c]  }|d|z  
 c}      }t        j
                  |      }t        j
                  |      }||k(  rJ  yc c}w )zt
    graph hashes should be invariant to node-relabeling (when the output is reindexed
    by the same mapping)
    r%   r         ?      r&   N)r(   r   erdos_renyi_graphrelabel_nodesr<   r   )	rA   r+   pr,   r   ur   g1_hashg2_hashs	            r   test_isomorphicrS   ]   s    
 DAqaA1a!e_ "!!!QUq9bbhhj"A1b1f9"AB11"511"5'!!!""As   B%c            
         d\  } }d|z  }t        d|dz         D ]#  }t        j                  | ||z  d|z         }|j                  D ]'  \  }}| d| d||   |   d<   | d| d	||   |   d
<   ) t        j                  |d      }t        j                  |d
      }t        j                  |d      }	||	k7  sJ ||	k7  sJ ||k7  sJ t        j
                  ||j                         D 
ci c]  }
|
d|
z  
 c}
      }t        j                  |d      }t        j                  |d
      }||k(  sJ ||k(  r$J  yc c}
w )a  
    Isomorphic graphs with differing edge attributes should yield different graph
    hashes if the 'edge_attr' argument is supplied and populated in the graph,
    and there are no hash collisions.
    The output should still be invariant to node-relabeling
    rH   rI   rJ   ,  r&   --1r   -2
edge_attr2r   NrL   )r(   r   rM   edgesr   rN   r<   )rA   r+   rO   r,   r   abg1_hash_with_edge_attr1g1_hash_with_edge_attr2g1_hash_no_edge_attrrP   r   g2_hash_with_edge_attr1g2_hash_with_edge_attr2s                 r   test_isomorphic_edge_attrrb   n   s    DAqaA1a!e_ B!!!QUq9HH 	2DAq()s!A3b\BqE!H\"()s!A3b\BqE!H\"	2 #%"A"A,#
 #%"A"A,#
  ">>rTR&*>>>>&*>>>>&*AAAAbbhhj"A1b1f9"AB"$"A"A,#
 #%"A"A,#
 '*AAAA&*AAAA;B& #Bs   .Ec                      t        j                         } | j                  ddddifddi fg       t        j                  t
        t         j                  | d       yzz
    If the 'edge_attr' argument is supplied but is missing from an edge in the graph,
    we should raise a KeyError
    rJ      r   r[      r   N)r   Graphadd_edges_fromr
   r   KeyErrorr   r@   s    r   test_missing_edge_attrrk      sL    
 	
Aq!lC01Aq":>?
MM(B;;Q,Wr#   c            
         d\  } }d|z  }t        d|dz         D ],  }t        j                  | ||z  d|z         }|j                         D ],  }| d|j                  |   d<   | d|j                  |   d	<   . t        j                  |d
      }t        j                  |d	
      }t        j                  |d
      }||k7  sJ ||k7  sJ ||k7  sJ t        j
                  ||j                         D ci c]  }|d|z  
 c}      }	t        j                  |	d
      }
t        j                  |	d	
      }||
k(  sJ ||k(  r-J  yc c}w )a  
    Isomorphic graphs with differing node attributes should yield different graph
    hashes if the 'node_attr' argument is supplied and populated in the graph, and
    there are no hash collisions.
    The output should still be invariant to node-relabeling
    rH   rI   rJ     r&   rW   r   rX   
node_attr2r   NrL   )r(   r   rM   r<   r   rN   )rA   r+   rO   r,   r   rP   g1_hash_with_node_attr1g1_hash_with_node_attr2g1_hash_no_node_attrr   g2_hash_with_node_attr1g2_hash_with_node_attr2s               r   test_isomorphic_node_attrrt      s    DAqaA1a!e_ B!!!QUq9 	1A+,#RBHHQK%+,#RBHHQK%	1 #%"A"A,#
 #%"A"A,#
  ">>rTR&*>>>>&*>>>>&*AAAAbbhhj"A1b1f9"AB"$"A"A,#
 #%"A"A,#
 '*AAAA&*AAAA;B& #Bs   7Ec                      t        j                         } | j                  dddifdi fg       | j                  g d       t	        j
                  t        t         j                  | d       yzy
    If the 'node_attr' argument is supplied but is missing from a node in the graph,
    we should raise a KeyError
    rJ   r   r[   re   )rJ   re   )re   rf   )rf   rJ   )rJ      r   N)r   rg   add_nodes_fromrh   r
   r   ri   r   rj   s    r   test_missing_node_attrrz      sW    
 	
Aq<-.B8956
MM(B;;Q,Wr#   c            
      \   d\  } }d|z  }t        d|dz         D ]  }t        j                  | ||z  d|z         }|j                         D ],  }| d|j                  |   d<   | d|j                  |   d	<   . |j                  D ]'  \  }}| d
| d||   |   d<   | d
| d||   |   d<   ) t        j
                  |dd      }t        j
                  |dd	      }	t        j
                  |dd	      }
t        j
                  |      }||k7  sJ |	|k7  sJ ||	k7  sJ |
|	k7  sJ |
|k7  sJ t        j                  ||j                         D ci c]  }|d|z  
 c}      }t        j
                  |dd      }t        j
                  |dd	      }||k(  sJ |	|k(  rJ  yc c}w )a  
    Isomorphic graphs with differing node attributes should yield different graph
    hashes if the 'node_attr' and 'edge_attr' argument is supplied and populated in
    the graph, and there are no hash collisions.
    The output should still be invariant to node-relabeling
    rH   rI   rJ     r&   rW   r   rX   rn   rV   r   rY   r   rL   N)r(   r   rM   r<   rZ   r   rN   )rA   r+   rO   r,   r   rP   r[   r\   g1_hash_edge1_node1g1_hash_edge2_node2g1_hash_edge1_node2g1_hash_no_attrr   g2_hash_edge1_node1g2_hash_edge2_node2s                  r   'test_isomorphic_edge_attr_and_node_attrr      s    DAqaA1a!e_ &:!!!QUq9 	1A+,#RBHHQK%+,#RBHHQK%	1 HH 	2DAq()s!A3b\BqE!H\"()s!A3b\BqE!H\"	2 !==,,
 !==,,
 !==,,
 99"="o555"o555"&9999"&9999"&9999bbhhj"A1b1f9"AB ==,,
 !==,,
 #&9999"&9999M&:8 #Bs   F)c                  "   d\  } }d|z  }t        d|dz         D ]s  }t        j                  | ||z  d|z         }t        j                  |      }t        j                  |d      }||k7  sJ t	        |      dk(  sJ t	        |      dk(  rsJ  y	)
d
    The hash string lengths should be as expected for a variety of graphs and
    digest sizes
    rH   rI   rJ     r&       digest_size@   N)r(   r   rM   r   len)rA   r+   rO   r,   r@   h16h32s          r   test_digest_sizer     s    
 DAqaA1a!e_ "  AEq9--a0--aR@czz3x6!!!3x6!!!"r#   c                     t        j                         } t        j                         }| j                  g d       |j                  g d       | j                  ddg       |j                  ddg       t        j                  |       }t        j                  |      }||k7  sJ t        j                         }|j                  g d       |j                  g d       |j                  ddg       t        j
                  |d	d
d
dddddd       t        j                  |      }t        j
                  |dddddd       t        j
                  |dddddd       t        j                  |dd      }t        j                  |dd      }||k(  sJ t        j                  |d      }t        j                  |d      }	||	k7  sJ y)zI
    These were bugs for directed graphs as discussed in issue #7806
    rJ   re   rf   rx   rw   rf   re   rf   rx   ))r   rx   )rJ   r3   )re      )rf      ))rx      )r3   r   )r   	   )r   r   )r   r   )r   r   sr[   r\   )r   r   r   rx   r3   r   r   weightdc)r   rJ   re   rf   rJ   )r   r   r   N)r   r:   ry   rh   r   r;   copydeepcopy)
GaGbGa_hashGb_hashTree1Tree2Tree1_hash_shortTree2_hash_short
Tree1_hash
Tree2_hashs
             r   test_directed_bugsr     s    
B	Bl#l#vv&'vv&'--b1G--b1GgJJLE	9:	9:	'7+,CCCCCCCH( MM% E5cccc"BHM5cccc"BHM66!x 66!x ////00J 00(KJ###r#   c                  :   d\  } }d|z  }t        d|dz         D ]~  }t        j                  | ||z  d|z         }t        j                  | ||z  d|z         }t        j                  |      }t        j                  |      }||k(  }t        j                  |dd       t        j                  |dd       t        j                  |d	      }	t        j                  |d	      }
|	|
k(  }t        j
                  |d
d       t        j
                  |d
d       t        j                  |d      }t        j                  |d      }||k(  }t        j                  |dd      }t        j                  |dd      }||k(  }||k(  sJ ||k(  sJ ||k(  rJ  y)zP
    Trivial labelling of the graph should not change isomorphism verdicts.
    rH   rI   rJ   r|   r&   *   r   valuesr8   r   r[   e_weightr   r   N)r(   r   rM   r   r;   set_edge_attributes)rA   r+   rO   r,   r   r   G1_hashG2_hashequalG1_hash_nodeG2_hash_node
equal_nodeG1_hash_edgeG2_hash_edge
equal_edgeG1_hash_bothG2_hash_both
equal_boths                     r   test_trivial_labels_isomorphismr   ?  s    DAqaA1a!e_ (!!!QUq9!!!QUa811"511"57"
r!(;
r!(;66rXN66rXN!\1

r#J?
r#J?66rZP66rZP!\1
66*
 66*
 "\1

"""Z'''Z''';(r#   c                  .   d\  } }d|z  }t        d|dz         D ]  }t        j                  | ||z  dd|z         }t        j                  | ||z  dd|z         }t        j                  |      }t        j                  |      }||k(  }t        j                  |dd	       t        j                  |dd	       t        j                  |d
      }	t        j                  |d
      }
|	|
k(  }t        j
                  |dd	       t        j
                  |dd	       t        j                  |d      }t        j                  |d      }||k(  }t        j                  |dd      }t        j                  |dd      }||k(  }||k(  sJ ||k(  sJ ||k(  rJ  t        j                         }|j                  g d       t        j                  |      }|j                  ddg       |j                  ddg       t        j                  |      }t        j                  |      }||k7  sJ t        j                  |dd	       t        j                  |dd	       t        j                  |d
      }t        j                  |d
      }||k7  sJ y)z\
    Trivial labelling of the graph should not change isomorphism verdicts on digraphs.
    rH   rI   rJ   Tr|   )directedr'   r   r   r   r   r[   r   r   r   r   rw   r   r   N)r(   r   rM   r   r;   r   r:   ry   r   r   rh   )rA   r+   rO   r,   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s                         r   (test_trivial_labels_isomorphism_directedr   e  su    DAqaA1a!e_ (!!!QUTaH!!!QUTQG11"511"57"
r!(;
r!(;66rXN66rXN!\1

r#J?
r#J?66rZP66rZP!\1
66*
 66*
 "\1

"""Z'''Z''';(B 
Bl#	r	Bvv&'vv&'--b1G--b1Gg 2ah72ah7--bHEG--bHEGgr#   c                     d\  } }d|z  }t        d|dz         D ]  }t        j                  | ||z  d|z         }t        j                  |dd       t        j                  |d	      }t        j
                  |dd
       t        j                  |d
      }||k(  sJ t        j                  |d
d      }||k(  rJ  y)a7  
    Test that 'empty' labelling of nodes or edges shouldn't have a different impact
    on the calculated hash. Note that we cannot assume that trivial weights have no
    impact at all. Without (trivial) weights, a node will start with hashing its
    degree. This step is omitted when there are weights.
    rH   rI   rJ   r|   r&    r   r   r   r   r   r   N)r(   r   rM   r;   r   r   )rA   r+   rO   r,   r   firstsecondthirds           r   test_trivial_labels_hashesr     s     DAqaA1a!e_ 
!!!QUq9
r"8<//hG
r":>00zJ//*
 
r#   c                 H    t        fd| j                         D              S )z
    returns True if that each hash sequence in 'a' is a prefix for
    the corresponding sequence indexed by the same node in 'b'.
    c              3   L   K   | ]  \  }}|   d t        |       |k(    y wNr   ).0nodehashesr\   s      r   	<genexpr>z"is_subiteration.<locals>.<genexpr>  s)     NLD&qw}V%/Ns   !$)allitems)r[   r\   s    `r   is_subiterationr     s    
 NAGGINNNr#   c                 ^    |dz  fdt        fd| j                         D              S )a
  
    returns True if all hex digest sizes are the expected length in a
    node:subgraph-hashes dictionary. Hex digest string length == 2 * bytes digest
    length since each pair of hex digits encodes 1 byte
    (https://docs.python.org/3/library/hashlib.html)
    re   c                 ,    t        fd| D              S )Nc              3   :   K   | ]  }t        |      k(    y wr   r   )r   xhexdigest_sizes     r   r   zMhexdigest_sizes_correct.<locals>.list_digest_sizes_correct.<locals>.<genexpr>  s     73q6^+7s   )r   )lr   s    r   list_digest_sizes_correctz:hexdigest_sizes_correct.<locals>.list_digest_sizes_correct  s    7Q777r#   c              3   .   K   | ]  } |        y wr    )r   r   r   s     r   r   z*hexdigest_sizes_correct.<locals>.<genexpr>  s     JV(0Js   )r   r   )r[   r   r   r   s     @@r   hexdigest_sizes_correctr     s,     !1_N8 JqxxzJJJr#   c                  T   t        j                         } t        j                  |       }t        j                  | d      }t        j                  | d      }t        j                  | d      }t        j                  | d      }|i k(  sJ |i k(  sJ |i k(  sJ |i k(  sJ |i k(  sJ y)	zZ "
    empty graphs should give empty dict subgraph hashes regardless of other params
    r   r   r   re   r   r   r   N)r   r	   r   )r@   subgraph_hashes1subgraph_hashes2subgraph_hashes3subgraph_hashes4subgraph_hashes5s         r   test_empty_graph_subgraph_hashr     s     	A;;A>;;AU;;AU;;A!L;;A2Nr!!!r!!!r!!!r!!!r!!!r#   c                      d} t        |       D ]e  }t        j                  d| z   d|z         }t        j                  |      }t        j                  |      }t        j                  |      }||k7  reJ  y)z
    A directed graph with no bi-directional edges should yield different subgraph
    hashes to the same graph taken as undirected, if all hashes don't collide.
    r   r%   r&   N)r(   r   r)   r*   r   )r+   r,   r-   r.   directed_subgraph_hashesundirected_subgraph_hashess         r   test_directed_subgraph_hashr     sw    
 	A1X F[[acAg6
''
3#%#G#G
#S %'%I%I,%W"'+EEEEFr#   c            
      ^   t        j                  dt         j                        } t        j                  | | j	                         D ci c]  }|t        |       c}d       | j                         }t        j                  | d      }t        j                  |d      }||k7  sJ yc c}w )z
    A directed graph with no bi-directional edges should yield different subgraph
    hashes to the same graph taken with edge directions reversed if there are no
    hash collisions. Here we test a cycle graph which is the minimal counterexample
    r3   r4   r6   r7   r   N)r   r9   r:   r;   r<   r=   r>   r   r?   s        r   test_reversed_subgraph_hashr     s     	qrzz2A1!'')<Qq#a&y<7KJ
,,Q'BA55jGTJ
?? =rF   c            
         d\  } }d|z  }t        d|dz         D ]  }t        j                  | ||z  d|z         }t        j                  ||j	                         D ci c]  }|d|z  
 c}      }t        j
                  |      }t        j
                  |      }||j                         D 	
ci c]  \  }	}
d|	z  |
 c}
}	k(  rJ  yc c}w c c}
}	w )z
    the subgraph hashes should be invariant to node-relabeling when the output is
    reindexed by the same mapping and all hashes don't collide.
    rH   rI   rJ   rK   r&   rL   N)r(   r   rM   rN   r<   r   r   )rA   r+   rO   r,   r   rP   r   g1_subgraph_hashesg2_subgraph_hasheskvs              r   test_isomorphic_subgraph_hashr     s    
 DAqaA1a!e_ X!!!QUq9bbhhj"A1b1f9"ABAA"EAA"E!<N<T<T<V%WDAqb1fai%WWWWX"A
 &Xs   C
/C
c            
      :   d\  } }d|z  }t        d|dz         D ]m  }t        j                  | ||z  d|z         }|j                  D ]'  \  }}| d| d||   |   d<   | d| d	||   |   d
<   ) t        j                  |d      }t        j                  |d
      }t        j                  |d      }	||	k7  sJ ||	k7  sJ ||k7  sJ t        j
                  ||j                         D 
ci c]  }
|
d|
z  
 c}
      }t        j                  |d      }t        j                  |d
      }||j                         D ci c]  \  }}d|z  | c}}k(  sJ ||j                         D ci c]  \  }}d|z  | c}}k(  rnJ  yc c}
w c c}}w c c}}w )a  
    Isomorphic graphs with differing edge attributes should yield different subgraph
    hashes if the 'edge_attr' argument is supplied and populated in the graph, and
    all hashes don't collide.
    The output should still be invariant to node-relabeling
    rH   rI   rJ   rU   r&   rV   rW   r   rX   rY   r   NrL   )r(   r   rM   rZ   r   rN   r<   r   )rA   r+   rO   r,   r   r[   r\   r]   r^   r_   rP   r   r`   ra   r   r   s                   r   'test_isomorphic_edge_attr_subgraph_hashr     s    DAqaA1a!e_ !
!!!QUq9HH 	2DAq()s!A3b\BqE!H\"()s!A3b\BqE!H\"	2 #%"F"F,#
 #%"F"F,#
  "CCBRVW&*>>>>&*>>>>&*AAAAbbhhj"A1b1f9"AB"$"F"F,#
 #%"F"F,#
 '"9"?"?"A+
!QBFAI+
 
 	
 
 '"9"?"?"A+
!QBFAI+
 
 	
 
?!
& #B+
+
s   .FF
0F
c                      t        j                         } | j                  ddddifddi fg       t        j                  t
        t         j                  | d       yrd   )r   rg   rh   r
   r   ri   r   rj   s    r   $test_missing_edge_attr_subgraph_hashr   ?  sO    
 	
Aq!lC01Aq":>?
MM"66\r#   c            
      L   d\  } }d|z  }t        d|dz         D ]v  }t        j                  | ||z  d|z         }|j                         D ],  }| d|j                  |   d<   | d|j                  |   d	<   . t        j                  |d
      }t        j                  |d	
      }t        j                  |d
      }||k7  sJ ||k7  sJ ||k7  sJ t        j
                  ||j                         D ci c]  }|d|z  
 c}      }	t        j                  |	d
      }
t        j                  |	d	
      }||
j                         D ci c]  \  }}d|z  | c}}k(  sJ ||j                         D ci c]  \  }}d|z  | c}}k(  rwJ  yc c}w c c}}w c c}}w )a  
    Isomorphic graphs with differing node attributes should yield different subgraph
    hashes if the 'node_attr' argument is supplied and populated in the graph, and
    all hashes don't collide.
    The output should still be invariant to node-relabeling
    rH   rI   rJ   rm   r&   rW   r   rX   rn   r   NrL   )r(   r   rM   r<   r   rN   r   )rA   r+   rO   r,   r   rP   ro   rp   rq   r   rr   rs   r   r   s                 r   'test_isomorphic_node_attr_subgraph_hashr   K  s    DAqaA1a!e_ !
!!!QUq9 	1A+,#RBHHQK%+,#RBHHQK%	1 #%"F"F,#
 #%"F"F,#
  "CCBRVW&*>>>>&*>>>>&*AAAAbbhhj"A1b1f9"AB"$"F"F,#
 #%"F"F,#
 '"9"?"?"A+
!QBFAI+
 
 	
 
 '"9"?"?"A+
!QBFAI+
 
 	
 
?!
& #B+
+
s   7FF
9F 
c                      t        j                         } | j                  dddifdi fg       | j                  g d       t	        j
                  t        t         j                  | d       yrv   )r   rg   ry   rh   r
   r   ri   r   rj   s    r   $test_missing_node_attr_subgraph_hashr   x  sZ    
 	
Aq<-.B8956
MM"66\r#   c            
         d\  } }d|z  }t        d|dz         D ]  }t        j                  | ||z  d|z         }|j                         D ],  }| d|j                  |   d<   | d|j                  |   d	<   . |j                  D ]'  \  }}| d
| d||   |   d<   | d
| d||   |   d<   ) t        j
                  |dd      }t        j
                  |dd	      }	t        j
                  |dd	      }
t        j
                  |      }||k7  sJ |	|k7  sJ ||	k7  sJ |
|	k7  sJ |
|k7  sJ t        j                  ||j                         D ci c]  }|d|z  
 c}      }t        j
                  |dd      }t        j
                  |dd	      }||j                         D ci c]  \  }}d|z  | c}}k(  sJ |	|j                         D ci c]  \  }}d|z  | c}}k(  rJ  yc c}w c c}}w c c}}w )a  
    Isomorphic graphs with differing node attributes should yield different subgraph
    hashes if the 'node_attr' and 'edge_attr' argument is supplied and populated in
    the graph, and all hashes don't collide
    The output should still be invariant to node-relabeling
    rH   rI   rJ   r|   r&   rW   r   rX   rn   rV   r   rY   r   rL   N)r(   r   rM   r<   rZ   r   rN   r   )rA   r+   rO   r,   r   rP   r[   r\   r}   r~   r   r   r   r   r   r   r   s                    r   5test_isomorphic_edge_attr_and_node_attr_subgraph_hashr     st    DAqaA1a!e_ *
!!!QUq9 	1A+,#RBHHQK%+,#RBHHQK%	1 HH 	2DAq()s!A3b\BqE!H\"()s!A3b\BqE!H\"	2 !BB,,
 !BB,,
 !BB,,
 >>rB"o555"o555"&9999"&9999"&9999bbhhj"A1b1f9"AB BB,,
 !BB,,
 #"5";";"='
!QBFAI'
 
 	
 
 #"5";";"='
!QBFAI'
 
 	
 
Q*
8 #B'
'
s   G3+G8
G>
c                  &   d\  } }d|z  }t        d|dz         D ]  }t        j                  | ||z  d|z         }t        j                  |d      }t        j                  |d      }t        j                  |d	      }t	        d
 |j                         D              sJ t	        d |j                         D              sJ t	        d |j                         D              sJ t        ||      sJ t        ||      sJ t        ||      rJ  y)z
    All nodes should have the correct number of subgraph hashes in the output when
    using degree as initial node labels.
    Subsequent iteration depths for the same graph should be additive for each node
    rH   rI   rJ   iX  r&   rf   r   rx   r3   c              3   8   K   | ]  }t        |      d k(    ywrf   Nr   r   r   s     r   r   z'test_iteration_depth.<locals>.<genexpr>       B3v;!#B   c              3   8   K   | ]  }t        |      d k(    ywrx   Nr   r   s     r   r   z'test_iteration_depth.<locals>.<genexpr>  r   r   c              3   8   K   | ]  }t        |      d k(    ywr3   Nr   r   s     r   r   z'test_iteration_depth.<locals>.<genexpr>  r   r   N)r(   r   rM   r   r   r   r   )rA   r+   rO   r,   r@   depth3depth4depth5s           r   test_iteration_depthr    s     DAqaA1a!e_ /  AEa855aAF55aAF55aAFB&--/BBBBB&--/BBBBB&--/BBBBvv...vv...vv.../r#   c                  z   d\  } }d|z  }t        d|dz         D ]  }t        j                  | ||z  d|z         }|j                  D ]  \  }}| d| d||   |   d<    t        j                  |dd	
      }t        j                  |dd
      }t        j                  |dd
      }	t        d |j                         D              sJ t        d |j                         D              sJ t        d |	j                         D              sJ t        ||      sJ t        ||	      sJ t        ||	      rJ  y)a  
    All nodes should have the correct number of subgraph hashes in the output when
    setting initial node labels empty and using an edge attribute when aggregating
    neighborhoods.
    Subsequent iteration depths for the same graph should be additive for each node
    rH   rI   rJ   i  r&   rV   rW   r   rf   )r   r   rx   r3   c              3   8   K   | ]  }t        |      d k(    ywr   r   r   s     r   r   z1test_iteration_depth_edge_attr.<locals>.<genexpr>  r   r   c              3   8   K   | ]  }t        |      d k(    ywr   r   r   s     r   r   z1test_iteration_depth_edge_attr.<locals>.<genexpr>  r   r   c              3   8   K   | ]  }t        |      d k(    ywr   r   r   s     r   r   z1test_iteration_depth_edge_attr.<locals>.<genexpr>  r   r   N)r(   r   rM   rZ   r   r   r   r   )
rA   r+   rO   r,   r@   r[   r\   r   r  r  s
             r   test_iteration_depth_edge_attrr    sK    DAqaA1a!e_ /  AEa8GG 	1DAq'(c1#RLAaDGL!	1 55!
 55!
 55!
 B&--/BBBBB&--/BBBBB&--/BBBBvv...vv...vv...-/r#   c                     d\  } }d|z  }t        d|dz         D ]#  }t        j                  | ||z  d|z         }|j                         D ]  }| d|j                  |   d<    t        j                  |dd	      }t        j                  |dd
	      }t        j                  |dd	      }t        d |j                         D              sJ t        d |j                         D              sJ t        d |j                         D              sJ t        ||      sJ t        ||      sJ t        ||      r$J  y)z
    All nodes should have the correct number of subgraph hashes in the output when
    setting initial node labels to an attribute.
    Subsequent iteration depths for the same graph should be additive for each node
    rH   rI   rJ   i   r&   rW   r   rf   )r   r   rx   r3   c              3   8   K   | ]  }t        |      d k(    ywr   r   r   s     r   r   z1test_iteration_depth_node_attr.<locals>.<genexpr>  r   r   c              3   8   K   | ]  }t        |      d k(    ywr   r   r   s     r   r   z1test_iteration_depth_node_attr.<locals>.<genexpr>  r   r   c              3   8   K   | ]  }t        |      d k(    ywr   r   r   s     r   r   z1test_iteration_depth_node_attr.<locals>.<genexpr>  r   r   N)r(   r   rM   r<   r   r   r   r   )	rA   r+   rO   r,   r@   rP   r   r  r  s	            r   test_iteration_depth_node_attrr    sC    DAqaA1a!e_ /  AEa8 	0A*+BxAGGAJ|$	0 55!
 55!
 55!
 B&--/BBBBB&--/BBBBB&--/BBBBvv...vv...vv...-/r#   c                     d\  } }d|z  }t        d|dz         D ]K  }t        j                  | ||z  d|z         }|j                         D ]  }| d|j                  |   d<    |j                  D ]  \  }}| d| d||   |   d	<    t        j
                  |d	dd
      }t        j
                  |d	dd      }	t        j
                  |d	dd      }
t        d |j                         D              sJ t        d |	j                         D              sJ t        d |
j                         D              sJ t        ||	      sJ t        |	|
      sJ t        ||
      rLJ  y)a!  
    All nodes should have the correct number of subgraph hashes in the output when
    setting initial node labels to an attribute and also using an edge attribute when
    aggregating neighborhoods.
    Subsequent iteration depths for the same graph should be additive for each node
    rH   rI   rJ   i  r&   rW   r   rV   r   rf   )r   r   r   rx   r3   c              3   8   K   | ]  }t        |      d k(    ywr   r   r   s     r   r   z6test_iteration_depth_node_edge_attr.<locals>.<genexpr>2  r   r   c              3   8   K   | ]  }t        |      d k(    ywr   r   r   s     r   r   z6test_iteration_depth_node_edge_attr.<locals>.<genexpr>3  r   r   c              3   8   K   | ]  }t        |      d k(    ywr   r   r   s     r   r   z6test_iteration_depth_node_edge_attr.<locals>.<genexpr>4  r   r   N)	r(   r   rM   r<   rZ   r   r   r   r   )rA   r+   rO   r,   r@   rP   r[   r\   r   r  r  s              r   #test_iteration_depth_node_edge_attrr    s    DAqaA1a!e_ /  AEa8 	0A*+BxAGGAJ|$	0 GG 	1DAq'(c1#RLAaDGL!	1 55!
 55!
 55!
 B&--/BBBBB&--/BBBBB&--/BBBBvv...vv...vv...3/r#   c                     d\  } }d|z  }t        d|dz         D ]o  }t        j                  | ||z  d|z         }t        j                  |      }t        j                  |d      }||k7  sJ t	        |d      sJ t	        |d      roJ  y	)
r   rH   rI   rJ   r   r&   r   r      N)r(   r   rM   r   r   )rA   r+   rO   r,   r@   digest_size16_hashesdigest_size32_hashess          r   test_digest_size_subgraph_hashr  ;  s    
 DAqaA1a!e_ 	A  AEq9!CCAF!CCASUV#';;;;&';R@@@&';R@@@	Ar#   c                     t        j                  d      } t        j                  | | D ci c]  }|t        d|cxk  xr dk  nc        c}d       t        j                  | d      }t        d |j                         D              sJ t        |j                         D ch c]  }|d   	 c}      dk(  sJ t        j                  | dd	      }t        d
 |j                         D              sJ t        |j                         D ch c]  }|d   	 c}      dk(  sJ | D ](  }t        ||   dd ||   d      D ]  \  }}||k(  rJ  * yc c}w c c}w c c}w )zP
    Including the hashed initial label prepends an extra hash to the lists
    r3   r   rx   r6   r   c              3   8   K   | ]  }t        |      d k(    ywr   r   r   r   s     r   r   z9test_initial_node_labels_subgraph_hash.<locals>.<genexpr>X  s     Cqs1v{Cr   rf   T)r   include_initial_labelsc              3   8   K   | ]  }t        |      d k(    ywr   r   r  s     r   r   z9test_initial_node_labels_subgraph_hash.<locals>.<genexpr>_  s     @qs1v{@r   re   rJ   N)strict)	r   
path_graphr;   intr   r   r   r   zip)r@   r,   without_initial_labelr   with_initial_labelrP   r[   r\   s           r   &test_initial_node_labels_subgraph_hashr#  N  sa    	aA1!<Qq#a!iai.0<gF @@gVC$9$@$@$BCCCC3::<=!=>!CCC==	WT @$6$=$=$?@@@@0779:!:;q@@@  q!!"%'<Q'?
 	DAq 6M6	# = > ;s   !E
#EE)$r   r
   networkxr   r   r"   r1   rE   rS   rb   rk   rt   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r#  r   r#   r   <module>r%     s      
?6.* """&BRX&BRX/:d"$#$L#(L5p2OK"&F "X"*
Z	*
Z
3
l/0/D/B"/JA&r#   