§
    bŠtj‘  ã                   ó:   — d Z ddlZdgZej        dd„¦   «         ZdS )zBBasic algorithms for breadth-first searching the nodes of a graph.é    NÚbfs_beam_edgesc              #   óx   ‡ ‡‡K  — ‰€t          ‰ ¦  «        Šˆ ˆˆfd„}t          j        ‰ ||¦  «        E d{V —† dS )a*  Iterates over edges in a beam search.

    The beam search is a generalized breadth-first search in which only
    the "best" *w* neighbors of the current node are enqueued, where *w*
    is the beam width and "best" is an application-specific
    heuristic. In general, a beam search with a small beam width might
    not visit each node in the graph.

    .. note::

       With the default value of ``width=None`` or `width` greater than the
       maximum degree of the graph, this function equates to a slower
       version of `~networkx.algorithms.traversal.breadth_first_search.bfs_edges`.
       All nodes will be visited, though the order of the reported edges may
       vary. In such cases, `value` has no effect - consider using `bfs_edges`
       directly instead.

    Parameters
    ----------
    G : NetworkX graph

    source : node
        Starting node for the breadth-first search; this function
        iterates over only those edges in the component reachable from
        this node.

    value : function
        A function that takes a node of the graph as input and returns a
        real number indicating how "good" it is. A higher value means it
        is more likely to be visited sooner during the search. When
        visiting a new node, only the `width` neighbors with the highest
        `value` are enqueued (in decreasing order of `value`).

    width : int (default = None)
        The beam width for the search. This is the number of neighbors
        (ordered by `value`) to enqueue when visiting each new node.

    Yields
    ------
    edge
        Edges in the beam search starting from `source`, given as a pair
        of nodes.

    Examples
    --------
    To give nodes with, for example, a higher centrality precedence
    during the search, set the `value` function to return the centrality
    value of the node:

    >>> G = nx.karate_club_graph()
    >>> centrality = nx.eigenvector_centrality(G)
    >>> list(nx.bfs_beam_edges(G, source=0, value=centrality.get, width=3))
    [(0, 2), (0, 1), (0, 8), (2, 32), (1, 13), (8, 33)]
    Nc                 óx   •— t          t          ‰                     | ¦  «        ‰d¬¦  «        d‰…         ¦  «        S )a  Returns a list of the best neighbors of a node.

        `v` is a node in the graph `G`.

        The "best" neighbors are chosen according to the `value`
        function (higher is better). Only the `width` best neighbors of
        `v` are returned.
        T)ÚkeyÚreverseN)ÚiterÚsortedÚ	neighbors)ÚvÚGÚvalueÚwidths    €€€úf/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/networkx/algorithms/traversal/beamsearch.pyÚ
successorsz"bfs_beam_edges.<locals>.successorsD   s5   ø€ õ( •F˜1Ÿ;š; q™>œ>¨u¸dÐCÑCÔCÀFÀUÀFÔKÑLÔLÐLó    )ÚlenÚnxÚgeneric_bfs_edges)r   Úsourcer   r   r   s   ` `` r   r   r      su   øøøè è € ðr €}Ý�A‘”ˆðMð Mð Mð Mð Mð Mð Mõ, Ô# A v¨zÑ:Ô:Ð:Ð:Ð:Ð:Ð:Ð:Ð:Ð:Ð:r   )N)Ú__doc__Únetworkxr   Ú__all__Ú_dispatchabler   © r   r   ú<module>r      sS   ðØ HÐ Hà Ð Ð Ð àÐ
€ð ÔðQ;ð Q;ð Q;ñ ÔðQ;ð Q;ð Q;r   