
    \Mh(	                         d Z ddlZddlmZmZ dgZ ed           ed          ej        dd                                    ZdS )	z=
Algorithm to find a maximal (not maximum) independent set.

    N)not_implemented_forpy_random_statemaximal_independent_setdirected   c                     |s$|                     t                               h}nt          |          }|                               st	          j        | d          t          j         fd|D              }t                              ||          rt	          j        | d          t          |          }t                                                     	                    |                    |                    }|rj|                     t          |                    }|
                    |           |                    t           j        |                   |gz              |j|S )a'  Returns a random maximal independent set guaranteed to contain
    a given set of nodes.

    An independent set is a set of nodes such that the subgraph
    of G induced by these nodes contains no edges. A maximal
    independent set is an independent set such that it is not possible
    to add a new node and still get an independent set.

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

    nodes : list or iterable
       Nodes that must be part of the independent set. This set of nodes
       must be independent.

    seed : integer, random_state, or None (default)
        Indicator of random number generation state.
        See :ref:`Randomness<randomness>`.

    Returns
    -------
    indep_nodes : list
       List of nodes that are part of a maximal independent set.

    Raises
    ------
    NetworkXUnfeasible
       If the nodes in the provided list are not part of the graph or
       do not form an independent set, an exception is raised.

    NetworkXNotImplemented
        If `G` is directed.

    Examples
    --------
    >>> G = nx.path_graph(5)
    >>> nx.maximal_independent_set(G)  # doctest: +SKIP
    [4, 0, 2]
    >>> nx.maximal_independent_set(G, [1])  # doctest: +SKIP
    [1, 3]

    Notes
    -----
    This algorithm does not solve the maximum independent set problem.

    z" is not a subset of the nodes of Gc                 D    g | ]}t          j        |                   S  )setadj).0vGs     W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/networkx/algorithms/mis.py
<listcomp>z+maximal_independent_set.<locals>.<listcomp>E   s%    999aCaMM999    z is not an independent set of G)choicelistr   issubsetnxNetworkXUnfeasibleunionintersectionnodes
differenceappenddifference_updater   )r   r   seed	neighborsindep_nodesavailable_nodesnodes   `      r   r   r      sb   f  T!WW%%&E

>>! R#u$P$P$PQQQ	99995999:I
	5)) O#u$M$M$MNNNu++K!''))nn//	0F0FGGO
 F{{400114   ))$quT{*;*;tf*DEEE  F r   )NN)	__doc__networkxr   networkx.utilsr   r   __all___dispatchabler   r
   r   r   <module>r(      s    
     ? ? ? ? ? ? ? ?$
% Z  ? ? ?   ! ? ? ?r   