§
    bŠtj9  ã                   ó¶   — d Z ddlmZ ddlZddlmZ ddgZ ed¦  «        ej        d„ ¦   «         ¦   «         Z	 ed¦  «        ej        d	„ ¦   «         ¦   «         Z
dS )
z
Dominance algorithms.
é    )ÚreduceN)Únot_implemented_forÚimmediate_dominatorsÚdominance_frontiersÚ
undirectedc                 ó°  ‡‡— || vrt          j        d¦  «        ‚|diŠt          t          j        | |¦  «        ¦  «        }d„ t	          |¦  «        D ¦   «         Š|                     ¦   «          |                     ¦   «          ˆˆfd„}d}|rGd}|D ]@}t          |ˆfd„| j        |         D ¦   «         ¦  «        }|‰vs‰|         |k    r|‰|<   d}ŒA|°G‰|= ‰S )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                 ó   — i | ]\  }}||“Œ	S © r
   )Ú.0ÚiÚus      ú[/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/networkx/algorithms/dominance.pyú
<dictcomp>z(immediate_dominators.<locals>.<dictcomp>D   s   € Ð
-Ð
-Ð
-‘D�A�qˆ1ˆaÐ
-Ð
-Ð
-ó    c                 óÐ   •— | |k    r^‰|          ‰|         k     r‰|          } ‰|          ‰|         k     °‰|          ‰|         k    r‰|         }‰|          ‰|         k    °| |k    °^| S ©Nr
   )r   ÚvÚdfnÚidoms     €€r   Ú	intersectz'immediate_dominators.<locals>.intersectH   sx   ø€ Ø�1ŠfˆfØ�a”&˜3˜qœ6’/�/Ø˜”G�ð �a”&˜3˜qœ6’/�/à�a”&˜3˜qœ6’/�/Ø˜”G�ð �a”&˜3˜qœ6’/�/ð �1Šfˆfð
 ˆr   TFc              3   ó$   •K  — | ]
}|‰v ¯|V — Œd S r   r
   )r   r   r   s     €r   ú	<genexpr>z'immediate_dominators.<locals>.<genexpr>T   s'   øè è € Ð)LÐ)L°À!ÀtÀ)À)¨!À)À)À)À)Ð)LÐ)Lr   )	ÚnxÚNetworkXErrorÚlistÚdfs_postorder_nodesÚ	enumerateÚpopÚreverser   Úpred)	ÚGÚstartÚorderr   Úchangedr   Únew_idomr   r   s	          @@r   r   r      s#  øø€ ðb �A€~€~ÝÔÐ2Ñ3Ô3Ð3à�4ˆ=€Då•Ô'¨¨5Ñ1Ô1Ñ2Ô2€EØ
-Ð
-�I eÑ,Ô,Ð
-Ñ
-Ô
-€CØ	‡I‚I�K„K€KØ	‡M‚M�O„O€Oðð ð ð ð ð ð €GØ
ð ØˆØð 	ð 	ˆAÝ˜iÐ)LÐ)LÐ)LÐ)L°Q´V¸A´YÐ)LÑ)LÔ)LÑMÔMˆHØ˜ˆ}ˆ}  Q¤¨8Ò 3Ð 3Ø"��Q‘Ø�øð ð ð 	ˆUˆØ€Kr   c                 óB  — t          j        | |¦  «        |diz  }d„ |D ¦   «         }|D ]u}||k    st          | j        |         ¦  «        dk    rO| j        |         D ]A}||v r;|||         k    r/||                              |¦  «         ||         }|||         k    °/ŒBŒv|S )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
    Nc                 ó,   — i | ]}|t          ¦   «         “ŒS r
   )Úset)r   r   s     r   r   z'dominance_frontiers.<locals>.<dictcomp>†   s   € Ð	!Ð	!Ð	!�qˆ!�S‰UŒUÐ	!Ð	!Ð	!r   é   )r   r   Úlenr    Úadd)r!   r"   r   Údfr   r   s         r   r   r   ]   sÀ   € õN Ô" 1 eÑ,Ô,°°t¨}Ñ<€Dà	!Ð	!˜DÐ	!Ñ	!Ô	!€BØð $ð $ˆØ�Š:ˆ:�˜QœV AœY™œ¨1Ò,Ð,Ø”V˜A”Yð $ð $�Ø˜�9�9Ø˜t Aœwš,˜,Ø˜1œŸ	š	 !™œ˜Ø  œG˜ð ˜t Aœwš,˜,øøð €Ir   )Ú__doc__Ú	functoolsr   Únetworkxr   Únetworkx.utilsr   Ú__all__Ú_dispatchabler   r   r
   r   r   ú<module>r3      sÄ   ððð ð Ð Ð Ð Ð Ð à Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .à!Ð#8Ð
9€ð Ð�\Ñ"Ô"ØÔðKð Kñ Ôñ #Ô"ðKð\ Ð�\Ñ"Ô"ØÔð/ð /ñ Ôñ #Ô"ð/ð /ð /r   