ó
    …~i9  ã                   ó¤   • S r SSKJr  SSKrSSKJr  SS/r\" S5      \R                  S 5       5       r	\" S5      \R                  S	 5       5       r
g)
z
Dominance algorithms.
é    )ÚreduceN)Únot_implemented_forÚimmediate_dominatorsÚdominance_frontiersÚ
undirectedc                 óÖ  ^^	• X;  a  [         R                  " S5      eUS0m	[        [         R                  " X5      5      n[	        U5       VVs0 s H  u  p4XC_M	     snnmUR                  5         UR                  5         UU	4S jnSnU(       aO  SnU H>  n[        UU	4S jU R                  U    5       5      nUT	;  d  T	U   U:w  d  M7  UT	U'   SnM@     U(       a  MO  T	U	 T	$ s  snnf )a  Returns the immediate dominators of all nodes of a directed graph.

Parameters
----------
G : a DiGraph or MultiDiGraph
    The graph where dominance is to be computed.

start : node
    The start node of dominance computation.

Returns
-------
idom : dict keyed by nodes
    A dict containing the immediate dominators of each node reachable from
    `start`, except for `start` itself.

Raises
------
NetworkXNotImplemented
    If `G` is undirected.

NetworkXError
    If `start` is not in `G`.

Notes
-----
The immediate dominators are the parents of their corresponding nodes in
the dominator tree. Every node reachable from `start` has an immediate
dominator, except for `start` itself.

Examples
--------
>>> G = nx.DiGraph([(1, 2), (1, 3), (2, 5), (3, 4), (4, 5)])
>>> sorted(nx.immediate_dominators(G, 1).items())
[(2, 1), (3, 1), (4, 3), (5, 1)]

References
----------
.. [1] Cooper, Keith D., Harvey, Timothy J. and Kennedy, Ken.
       "A simple, fast dominance algorithm." (2006).
       https://hdl.handle.net/1911/96345
.. [2] Lengauer, Thomas; Tarjan, Robert Endre (July 1979).
       "A fast algorithm for finding dominators in a flowgraph".
       ACM Transactions on Programming Languages and Systems. 1 (1): 121--141.
       https://dl.acm.org/doi/10.1145/357062.357071
zstart is not in GNc                 óœ   >• X:w  aE  TU    TU   :  a  TU    n TU    TU   :  a  M  TU    TU   :”  a  TU   nTU    TU   :”  a  M  X:w  a  ME  U $ ©N© )ÚuÚvÚdfnÚidoms     €€ÚZ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/algorithms/dominance.pyÚ	intersectÚ'immediate_dominators.<locals>.intersectH   sh   ø€ Ø‹fØ�a‘&˜3˜q™6“/Ø˜‘G�ð �a‘&˜3˜q™6•/à�a‘&˜3˜q™6“/Ø˜‘G�ð �a‘&˜3˜q™6•/ð �fð
 ˆó    TFc              3   ó6   >#   • U  H  oT;   d  M
  Uv •  M     g 7fr
   r   )Ú.0r   r   s     €r   Ú	<genexpr>Ú'immediate_dominators.<locals>.<genexpr>T   s   øé € Ð)L²Y°ÀtÁ)¯!©!²Yùs   ƒ	�	)	ÚnxÚNetworkXErrorÚlistÚdfs_postorder_nodesÚ	enumerateÚpopÚreverser   Úpred)
ÚGÚstartÚorderÚir   r   ÚchangedÚnew_idomr   r   s
           @@r   r   r      sÞ   ù€ ðb ƒ~Ü×ÒÐ2Ó3Ð3à�4ˆ=€Dä”×'Ò'¨Ó1Ó2€EÜ% eÔ,Ô
-Ò,‘D�Aˆ1Š4Ñ,Ò
-€CØ	‡I�I„KØ	‡M�M„Oöð €GÞ
ØˆÛˆAÜ˜iÔ)L°Q·V±V¸A²YÓ)LÓMˆHØ˜‹}  Q¡¨8Õ 3Ø"��Q‘Ø’ñ	 ÷ ˆ'ð 	ˆUˆØ€Kùó- .s   ÁC%c                 ób  • [         R                  " X5      US0-  nU Vs0 s H  o3[        5       _M     nnU Hn  nX1:X  d  [        U R                  U   5      S:¼  d  M&  U R                  U    H5  nXR;   d  M
  XRU   :w  d  M  XE   R                  U5        X%   nXRU   :w  a  M!  M7     Mp     U$ s  snf )a\  Returns the dominance frontiers of all nodes of a directed graph.

Parameters
----------
G : a DiGraph or MultiDiGraph
    The graph where dominance is to be computed.

start : node
    The start node of dominance computation.

Returns
-------
df : dict keyed by nodes
    A dict containing the dominance frontiers of each node reachable from
    `start` as lists.

Raises
------
NetworkXNotImplemented
    If `G` is undirected.

NetworkXError
    If `start` is not in `G`.

Examples
--------
>>> G = nx.DiGraph([(1, 2), (1, 3), (2, 5), (3, 4), (4, 5)])
>>> sorted((u, sorted(df)) for u, df in nx.dominance_frontiers(G, 1).items())
[(1, []), (2, [5]), (3, [5]), (4, [5]), (5, [])]

References
----------
.. [1] Cooper, Keith D., Harvey, Timothy J. and Kennedy, Ken.
       "A simple, fast dominance algorithm." (2006).
       https://hdl.handle.net/1911/96345
Né   )r   r   ÚsetÚlenr   Úadd)r    r!   r   r   Údfr   s         r   r   r   ]   s£   € ôN ×"Ò" 1Ó,°°t¨}Ñ<€Dá Ó	!šD�qŒS‹UŠ(™D€BÐ	!ÛˆØ‹:œ˜QŸV™V A™Y›¨1Õ,Ø—V‘V˜A”Y�Ø•9Ø A™w�,Ø™Ÿ	™	 !œØ ™G˜ð  A™wŸ,ó ñ ð €Iùò 
"s    B,)Ú__doc__Ú	functoolsr   Únetworkxr   Únetworkx.utilsr   Ú__all__Ú_dispatchabler   r   r   r   r   Ú<module>r2      sq   ðñõ ã Ý .à!Ð#8Ð
9€ñ �\Ó"Ø×ÑñKó ó #ðKñ\ �\Ó"Ø×Ññ/ó ó #ñ/r   