
    h                         S r SSKr/ SQr\R                  S 5       r\R                  S 5       r\R                  S 5       rg)z8
Functions for identifying isolate (degree zero) nodes.
    N)
is_isolateisolatesnumber_of_isolatesc                 *    U R                  U5      S:H  $ )a  Determines whether a node is an isolate.

An *isolate* is a node with no neighbors (that is, with degree
zero). For directed graphs, this means no in-neighbors and no
out-neighbors.

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

n : node
    A node in `G`.

Returns
-------
is_isolate : bool
   True if and only if `n` has no neighbors.

Examples
--------
>>> G = nx.Graph()
>>> G.add_edge(1, 2)
>>> G.add_node(3)
>>> nx.is_isolate(G, 2)
False
>>> nx.is_isolate(G, 3)
True
r   degree)Gns     M/var/www/html/env/lib/python3.13/site-packages/networkx/algorithms/isolate.pyr   r   
   s    < 88A;!    c                 0    S U R                  5        5       $ )aX  Iterator over isolates in the graph.

An *isolate* is a node with no neighbors (that is, with degree
zero). For directed graphs, this means no in-neighbors and no
out-neighbors.

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

Returns
-------
iterator
    An iterator over the isolates of `G`.

Examples
--------
To get a list of all isolates of a graph, use the :class:`list`
constructor::

    >>> G = nx.Graph()
    >>> G.add_edge(1, 2)
    >>> G.add_node(3)
    >>> list(nx.isolates(G))
    [3]

To remove all isolates in the graph, first create a list of the
isolates, then use :meth:`Graph.remove_nodes_from`::

    >>> G.remove_nodes_from(list(nx.isolates(G)))
    >>> list(G)
    [1, 2]

For digraphs, isolates have zero in-degree and zero out_degre::

    >>> G = nx.DiGraph([(0, 1), (1, 2)])
    >>> G.add_node(3)
    >>> list(nx.isolates(G))
    [3]

c              3   :   #    U  H  u  pUS :X  d  M  Uv   M     g7f)r   N ).0r
   ds      r   	<genexpr>isolates.<locals>.<genexpr>V   s     /*$!QAA*s   	r   r	   s    r   r   r   +   s    V 0!((*//r   c                 8    [        S [        U 5       5       5      $ )a0  Returns the number of isolates in the graph.

An *isolate* is a node with no neighbors (that is, with degree
zero). For directed graphs, this means no in-neighbors and no
out-neighbors.

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

Returns
-------
int
    The number of degree zero nodes in the graph `G`.

c              3   &   #    U  H  nS v   M	     g7f)   Nr   )r   vs     r   r   %number_of_isolates.<locals>.<genexpr>k   s     &+Qq+s   )sumr   r   s    r   r   r   Y   s    $ &(1+&&&r   )__doc__networkxnx__all___dispatchabler   r   r   r   r   r   <module>r       sd    
:  @ *0 *0Z ' 'r   