
    çgm
                     t    d Z ddlmZ ddlZddlmZ ddgZej        d	d            Z	ej        d             Z
dS )
z3Functions for computing dominating sets in a graph.    )chainN)arbitrary_elementdominating_setis_dominating_setc                 \   t          |           }|t          |          }|| vrt          j        d| d          |h}t          | |                   }||z
  |z
  }|rM|                                }t          | |                   |z
  }|                    |           ||z  }||z  }|M|S )a\  Finds a dominating set for the graph G.

    A *dominating set* for a graph with node set *V* is a subset *D* of
    *V* such that every node not in *D* is adjacent to at least one
    member of *D* [1]_.

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

    start_with : node (default=None)
        Node to use as a starting point for the algorithm.

    Returns
    -------
    D : set
        A dominating set for G.

    Notes
    -----
    This function is an implementation of algorithm 7 in [2]_ which
    finds some dominating set, not necessarily the smallest one.

    See also
    --------
    is_dominating_set

    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/Dominating_set

    .. [2] Abdol-Hossein Esfahanian. Connectivity Algorithms.
        http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf

    Nznode z is not in G)setr   nxNetworkXErrorpopadd)G
start_with	all_nodesr   dominated_nodesremaining_nodesvundominated_nbrss           Z/var/www/html/ai-engine/env/lib/python3.11/site-packages/networkx/algorithms/dominating.pyr   r      s    J AI&y11
?z???@@@ \N!J-((O/1NBO
 	,!!qt99~5 	1++++  	,     c                       fd|D             }t          t          j         fd|D                                 }t          t                     |z
  |z
            dk    S )a  Checks if `nbunch` is a dominating set for `G`.

    A *dominating set* for a graph with node set *V* is a subset *D* of
    *V* such that every node not in *D* is adjacent to at least one
    member of *D* [1]_.

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

    nbunch : iterable
        An iterable of nodes in the graph `G`.

    See also
    --------
    dominating_set

    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/Dominating_set

    c                     h | ]}|v |	S  r   .0nr   s     r   	<setcomp>z$is_dominating_set.<locals>.<setcomp>]   s    +++QAFFqFFFr   c              3   (   K   | ]}|         V  d S Nr   r   s     r   	<genexpr>z$is_dominating_set.<locals>.<genexpr>^   s'      "9"9A1Q4"9"9"9"9"9"9r   r   )r   r   from_iterablelen)r   nbunchtestsetnbrss   `   r   r   r   E   sn    0 ,+++&+++Gu""9"9"9"9"9"9"999::Ds1vv$&''1,,r   r   )__doc__	itertoolsr   networkxr	   networkx.utilsr   __all___dispatchabler   r   r   r   r   <module>r+      s    9 9           , , , , , ,0
1 6 6 6 6r - - - - -r   