Ë
    pPêjw  ã                  óŠ   — d Z ddlmZ ddlmZmZ ddlmZ  ed«      Z		 	 	 	 	 	 dd„Z
	 	 	 	 	 	 dd„Z G d„ d	eee	      «      Zy
)z&Helpers for manipulations with graphs.é    )Úannotations)ÚIteratorÚSet)ÚTypeVarÚTc              #  óŠ   ‡‡‡‡‡‡K  — t        «       Šg Ši Šg Šdˆˆˆˆˆˆfd„Š| D ]  }|‰vsŒ ‰|«      E d{  –—†  Œ y7 Œ­w)aä  Compute Strongly Connected Components of a directed graph.

    Args:
      vertices: the labels for the vertices
      edges: for each vertex, gives the target vertices of its outgoing edges

    Returns:
      An iterator yielding strongly connected components, each
      represented as a set of vertices.  Each input vertex will occur
      exactly once; vertices not part of a SCC are returned as
      singleton sets.

    From https://code.activestate.com/recipes/578507/.
    c              3  ó¤  •K  — t        ‰«      ‰| <   ‰j                  | «       ‰j                  ‰|    «       ‰|    D ]D  }|‰vr ‰|«      E d {  –—†  Œ|‰vsŒ‰|   ‰d   k  sŒ)‰j                  «        ‰|   ‰d   k  rŒŒF ‰d   ‰|    k(  r?‰j                  «        t        ‰‰|    d  «      }‰‰|    d …= ‰j	                  |«       |–— y y 7 Œ­w)Néÿÿÿÿ)ÚlenÚappendÚpopÚsetÚupdate)	ÚvÚwÚsccÚ
boundariesÚdfsÚedgesÚ
identifiedÚindexÚstacks	      €€€€€€úU/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/mypy/graph_utils.pyr   z*strongly_connected_components.<locals>.dfs!   sè   øè ø€ Ü�u“:ˆˆa‰Ø�‰�QŒØ×Ñ˜% ™(Ô#à�q‘ò 	%ˆAØ˜‰~Ù˜q›6×!Ñ!Ø˜*Ò$Ø˜A‘h ¨B¡Ó/Ø—N‘NÔ$ð ˜A‘h ¨B¡Ô/ð		%ð �b‰>˜U 1™XÒ%Ø�N‰NÔÜ�e˜E !™H˜JÐ'Ó(ˆCØ�e˜A‘h‘jÐ!Ø×Ñ˜cÔ"Ø‹Ið &ð "ús%   ƒACÁCÁ	CÁCÁ%CÂACN)r   r   ÚreturnúIterator[set[T]])r   )Úverticesr   r   r   r   r   r   r   s    ` @@@@@r   Ústrongly_connected_componentsr      sQ   ýè ø€ ô" ›€JØ€EØ€EØ€J÷ò ð& ò ˆØ�EŠ>Ù˜1“v×Ññàús   ˆ%A®A¹AºAc                óÒ   ‡— i Š| D ]  }t        |«      }|D ]  }|‰|<   Œ	 Œ i }| D ]>  }t        «       }|D ]  }|j                  ˆfd„||   D «       «       Œ! ||t        |«      <   Œ@ |S )zLUse original edges to organize SCCs in a graph by dependencies between them.c              3  ó(   •K  — | ]	  }‰|   –— Œ y ­w©N© )Ú.0ÚxÚsccsmaps     €r   ú	<genexpr>zprepare_sccs.<locals>.<genexpr>F   s   øè ø€ Ò5 q˜ �
Ñ5ùs   ƒ)Ú	frozensetr   r   )Úsccsr   r   Ú
scc_frozenr   ÚdataÚdepsr$   s          @r   Úprepare_sccsr+   9   s‘   ø€ ð €GØò $ˆÜ˜s“^ˆ
Øò 	$ˆAØ#ˆG�AŠJñ	$ð$ð 79€DØò $ˆÜ$'£EˆØò 	6ˆAØ�K‰KÓ5¨E°!©HÔ5Õ5ð	6à#ˆŒY�s‹^Òð	$ð
 €Kó    c                  ó(   — e Zd ZdZdd„Zdd„Zdd„Zy)	Útopsorta�  Topological sort using Kahn's algorithm.

    Uses in-degree counters and a reverse adjacency list, so the total work
    is O(V + E).

    Implemented as a class rather than a generator for better mypyc
    compilation.

    Args:
      data: A map from vertices to all vertices that it has an edge
            connecting it to. NOTE: dependency sets in this data
            structure are modified in place to remove self-dependencies.
            Orphans are handled internally and are not added to `data`.

    Returns:
      An iterator yielding sets of vertices that have an equivalent
      ordering.

    Example:
      Suppose the input has the following structure:

        {A: {B, C}, B: {D}, C: {D}}

      The algorithm treats orphan dependencies as if normalized to:

        {A: {B, C}, B: {D}, C: {D}, D: {}}

      It will yield the following values:

        {D}
        {B, C}
        {A}
    c                ó´  — i }i }t        «       }|j                  «       D ]†  \  }}|j                  |«       t        |«      }|||<   |dk(  r|j	                  |«       ||vrg ||<   |D ]<  }||v r||   j                  |«       Œ|g||<   ||vsŒ'd||<   |j	                  |«       Œ> Œˆ || _        || _        || _        t        |«      t        |«      z
  | _	        y )Nr   )
r   ÚitemsÚdiscardr   Úaddr   Ú	in_degreeÚrevÚreadyÚ	remaining)	Úselfr)   r3   r4   r5   Úitemr*   ÚdegÚdeps	            r   Ú__init__ztopsort.__init__n   så   € ð #%ˆ	Ø "ˆÜ›ˆØŸ*™*›,ò 	'‰JˆD�$Ø�L‰L˜ÔÜ�d“)ˆCØ!ˆI�d‰OØ�aŠxØ—	‘	˜$”Ø˜3‰Ø��D‘	Øò '�Ø˜#‘:Ø˜‘H—O‘O DÕ)à $˜v�C˜‘HØ $’à)*˜	 #™ØŸ	™	 #�ñ'ð	'ð$ #ˆŒØˆŒØˆŒ
Ü˜Y›¬#¨e«*Ñ4ˆ�r,   c                ó   — | S r    r!   )r7   s    r   Ú__iter__ztopsort.__iter__‹   s   € Øˆr,   c                óÆ  — | j                   }|sP| j                  dk(  s;J d| j                  j                  «       D ��cg c]  \  }}|dkD  sŒ|‘Œ c}}›�«       ‚t        ‚| j                  }| j
                  }t        «       }|D ]0  }||   D ]&  }||   dz
  }	|	||<   |	dk(  sŒ|j                  |«       Œ( Œ2 | xj                  t        |«      z  c_        || _         |S c c}}w )Nr   z#A cyclic dependency exists amongst é   )	r5   r6   r3   r0   ÚStopIterationr4   r   r2   r   )
r7   r5   Úkr9   r3   r4   Ú	new_readyr8   Ú	dependentÚnew_degs
             r   Ú__next__ztopsort.__next__Ž   sí   € Ø—
‘
ˆÙØ—>‘> QÒ&ð Ø5Ø$(§N¡N×$8Ñ$8Ó$:×F™&˜!˜S¸cÀA»g’AÓFÐIðKóÐ&ô  ÐØ—N‘Nˆ	Ø�h‰hˆÜ›Eˆ	Øò 	-ˆDØ  ™Yò -�	Ø# IÑ.°Ñ2�Ø'.�	˜)Ñ$Ø˜a“<Ø—M‘M )Õ,ñ	-ð	-ð 	�Šœ#˜i›.Ñ(�ØˆŒ
Øˆùó Gs   ½C
ÁC
N)r)   zdict[T, set[T]]r   ÚNone)r   r   )r   zset[T])Ú__name__Ú
__module__Ú__qualname__Ú__doc__r;   r=   rE   r!   r,   r   r.   r.   K   s   „ ñ óD5ó:ôr,   r.   N)r   zAbstractSet[T]r   údict[T, list[T]]r   r   )r'   zlist[set[T]]r   rK   r   z)dict[AbstractSet[T], set[AbstractSet[T]]])rJ   Ú
__future__r   Úcollections.abcr   r   ÚAbstractSetÚtypingr   r   r   r+   r   r.   r!   r,   r   ú<module>rP      sl   ðÙ ,å "ç 8Ý áˆCƒL€ð+Øð+Ø%5ð+àó+ð\Ø
ðØ/ðà.óô$Vˆh�s˜1‘vÑõ Vr,   