§
    bŠtj²  ã                   ó4  — d Z ddlmZ ddlZddlmZ g d¢Z ed¦  «        ej        dd„¦   «         ¦   «         Z	 ed¦  «        ej        dd„¦   «         ¦   «         Z
 ed	¦  «         ed¦  «         ej        d
¬¦  «        dd„¦   «         ¦   «         ¦   «         ZdS )zBridge-finding algorithms.é    )ÚchainN)Únot_implemented_for)ÚbridgesÚhas_bridgesÚlocal_bridgesÚdirectedc              #   óä  K  — |                       ¦   «         }|rt          j        | ¦  «        n| }t          j        ||¬¦  «        }t	          t          j        |¦  «        ¦  «        }|�:|                     t          j        ||¦  «        ¦  «         	                    ¦   «         }| 
                    ¦   «         D ]9\  }}||f|vr.||f|vr(|r t          | |         |         ¦  «        dk    rŒ3||fV — Œ:dS )a@  Generate all bridges in a graph.

    A *bridge* in a graph is an edge whose removal causes the number of
    connected components of the graph to increase.  Equivalently, a bridge is an
    edge that does not belong to any cycle. Bridges are also known as cut-edges,
    isthmuses, or cut arcs.

    Parameters
    ----------
    G : undirected graph

    root : node (optional)
       A node in the graph `G`. If specified, only the bridges in the
       connected component containing this node will be returned.

    Yields
    ------
    e : edge
       An edge in the graph whose removal disconnects the graph (or
       causes the number of connected components to increase).

    Raises
    ------
    NodeNotFound
       If `root` is not in the graph `G`.

    NetworkXNotImplemented
        If `G` is a directed graph.

    Examples
    --------
    The barbell graph with parameter zero has a single bridge:

    >>> G = nx.barbell_graph(10, 0)
    >>> list(nx.bridges(G))
    [(9, 10)]

    Notes
    -----
    This is an implementation of the algorithm described in [1]_.  An edge is a
    bridge if and only if it is not contained in any chain. Chains are found
    using the :func:`networkx.chain_decomposition` function.

    The algorithm described in [1]_ requires a simple graph. If the provided
    graph is a multigraph, we convert it to a simple graph and verify that any
    bridges discovered by the chain decomposition algorithm are not multi-edges.

    Ignoring polylogarithmic factors, the worst-case time complexity is the
    same as the :func:`networkx.chain_decomposition` function,
    $O(m + n)$, where $n$ is the number of nodes in the graph and $m$ is
    the number of edges.

    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/Bridge_%28graph_theory%29#Bridge-Finding_with_Chain_Decompositions
    ©ÚrootNé   )Úis_multigraphÚnxÚGraphÚchain_decompositionÚsetr   Úfrom_iterableÚsubgraphÚnode_connected_componentÚcopyÚedgesÚlen)ÚGr   Ú
multigraphÚHÚchainsÚchain_edgesÚuÚvs           úY/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/networkx/algorithms/bridges.pyr   r      sþ   è è € ðv —’Ñ"Ô"€JØ!Ð(�Œ�‰Œˆ q€AÝÔ# A¨DÐ1Ñ1Ô1€FÝ•eÔ)¨&Ñ1Ô1Ñ2Ô2€KØÐØ�JŠJ•rÔ2°1°dÑ;Ô;Ñ<Ô<×AÒAÑCÔCˆØ—’‘	”	ð ð ‰ˆˆ1Øˆqˆ6˜Ð$Ð$¨!¨Q¨°{Ð)BÐ)BØð �c ! A¤$ q¤'™lœl¨QÒ.Ð.ØØ�Q�$ˆJˆJˆJøð	ð ó    c                 óf   — 	 t          t          | |¬¦  «        ¦  «         dS # t          $ r Y dS w xY w)aà  Decide whether a graph has any bridges.

    A *bridge* in a graph is an edge whose removal causes the number of
    connected components of the graph to increase.

    Parameters
    ----------
    G : undirected graph

    root : node (optional)
       A node in the graph `G`. If specified, only the bridges in the
       connected component containing this node will be considered.

    Returns
    -------
    bool
       Whether the graph (or the connected component containing `root`)
       has any bridges.

    Raises
    ------
    NodeNotFound
       If `root` is not in the graph `G`.

    NetworkXNotImplemented
        If `G` is a directed graph.

    Examples
    --------
    The barbell graph with parameter zero has a single bridge::

        >>> G = nx.barbell_graph(10, 0)
        >>> nx.has_bridges(G)
        True

    On the other hand, the cycle graph has no bridges::

        >>> G = nx.cycle_graph(5)
        >>> nx.has_bridges(G)
        False

    Notes
    -----
    This implementation uses the :func:`networkx.bridges` function, so
    it shares its worst-case time complexity, $O(m + n)$, ignoring
    polylogarithmic factors, where $n$ is the number of nodes in the
    graph and $m$ is the number of edges.

    r
   TF)Únextr   ÚStopIteration)r   r   s     r   r   r   S   sN   € ðhÝ�W�Q˜TÐ"Ñ"Ô"Ñ#Ô#Ð#ð ˆtøõ ð ð ð Øˆuˆuðøøøs   ‚" ¢
0¯0r   Úweight)Ú
edge_attrsTc              #   óî  ‡‡K  — |dur@| j         D ]6\  }}t          | |         ¦  «        t          | |         ¦  «        z  s||fV — Œ7dS t          j                             | |¦  «        Š| j         D ]„\  }}t          | |         ¦  «        t          | |         ¦  «        z  sT||hŠˆˆfd„}	 t          j        | |||¬¦  «        }|||fV — Œ[# t          j        $ r ||t          d¦  «        fV — Y Œ€w xY wŒ…dS )al  Iterate over local bridges of `G` optionally computing the span

    A *local bridge* is an edge whose endpoints have no common neighbors.
    That is, the edge is not part of a triangle in the graph.

    The *span* of a *local bridge* is the shortest path length between
    the endpoints if the local bridge is removed.

    Parameters
    ----------
    G : undirected graph

    with_span : bool
        If True, yield a 3-tuple `(u, v, span)`

    weight : function, string or None (default: None)
        If function, used to compute edge weights for the span.
        If string, the edge data attribute used in calculating span.
        If None, all edges have weight 1.

    Yields
    ------
    e : edge
        The local bridges as an edge 2-tuple of nodes `(u, v)` or
        as a 3-tuple `(u, v, span)` when `with_span is True`.

    Raises
    ------
    NetworkXNotImplemented
        If `G` is a directed graph or multigraph.

    Examples
    --------
    A cycle graph has every edge a local bridge with span N-1.

       >>> G = nx.cycle_graph(9)
       >>> (0, 8, 8) in set(nx.local_bridges(G))
       True
    Tc                 ó2   •— | ‰vs|‰vr ‰| ||¦  «        S d S ©N© )ÚnÚnbrÚdÚenodesÚwts      €€r   Ú	hide_edgez local_bridges.<locals>.hide_edgeÄ   s-   ø€ Ø ��¨#°VÐ*;Ð*;Ø!˜r ! S¨!™}œ}Ð,Ø˜4r    )r$   ÚinfN)r   r   r   ÚweightedÚ_weight_functionÚshortest_path_lengthÚNetworkXNoPathÚfloat)	r   Ú	with_spanr$   r   r   r/   Úspanr-   r.   s	          @@r   r   r   �   sY  øøè è € ðV ˜ÐÐØ”Gð 	ð 	‰DˆAˆqÝ˜˜!œ‘I”I¥ A a¤D¡	¤	Ñ)ð Ø˜�d�
�
�
øð	ð 	õ Œ[×)Ò)¨!¨VÑ4Ô4ˆØ”Gð 	-ð 	-‰DˆAˆqÝ˜˜!œ‘I”I¥ A a¤D¡	¤	Ñ)ð -Ø˜Q˜�ð ð  ð  ð  ð  ð  ð
-ÝÔ2°1°a¸À9ÐMÑMÔM�DØ˜Q ˜*Ð$Ð$Ð$Ð$øÝÔ(ð -ð -ð -Ø˜Q¥ e¡¤Ð,Ð,Ð,Ð,Ð,Ð,ð-øøøð-ð	-ð 	-s   Â+CÃ#C1Ã0C1r(   )TN)Ú__doc__Ú	itertoolsr   Únetworkxr   Únetworkx.utilsr   Ú__all__Ú_dispatchabler   r   r   r)   r    r   ú<module>r>      s'  ðØ  Ð  à Ð Ð Ð Ð Ð à Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .à
5Ð
5Ð
5€ð Ð�ZÑ Ô ØÔðCð Cð Cñ Ôñ !Ô ðCðL Ð�ZÑ Ô ØÔð7ð 7ð 7ñ Ôñ !Ô ð7ðt Ð�\Ñ"Ô"ØÐ�ZÑ Ô Ø€Ô˜XÐ&Ñ&Ô&ð;-ð ;-ð ;-ñ 'Ô&ñ !Ô ñ #Ô"ð;-ð ;-ð ;-r    