+
    )i                         R t ^ RIt^ RIHt ^RIHt . R
Ot]! R4      ]P                  R 4       4       t	]! R4      ]P                  R 4       4       t
]! R4      ]P                  R 4       4       t]! R4      ]P                  R 4       4       tR	 tR# )zConnected components.N)not_implemented_for)arbitrary_elementdirectedc              #     "   \        4       p\        V 4      pV  F<  pW19  g   K  \        W\        V4      ,
          V4      pVP                  V4       Vx  K>  	  R# 5i)a  Generate connected components.

The connected components of an undirected graph partition the graph into
disjoint sets of nodes. Each of these sets induces a subgraph of graph
`G` that is connected and not part of any larger connected subgraph.

A graph is connected (:func:`is_connected`) if, for every pair of distinct
nodes, there is a path between them. If there is a pair of nodes for
which such path does not exist, the graph is not connected (also referred
to as "disconnected").

A graph consisting of a single node and no edges is connected.
Connectivity is undefined for the null graph (graph with no nodes).

Parameters
----------
G : NetworkX graph
   An undirected graph

Yields
------
comp : set
   A set of nodes in one connected component of the graph.

Raises
------
NetworkXNotImplemented
    If G is directed.

Examples
--------
Generate a sorted list of connected components, largest first.

>>> G = nx.path_graph(4)
>>> nx.add_path(G, [10, 11, 12])
>>> [len(c) for c in sorted(nx.connected_components(G), key=len, reverse=True)]
[4, 3]

If you only want the largest connected component, it's more
efficient to use max instead of sort.

>>> largest_cc = max(nx.connected_components(G), key=len)

To create the induced subgraph of each component use:

>>> S = [G.subgraph(c).copy() for c in nx.connected_components(G)]

See Also
--------
number_connected_components
is_connected
number_weakly_connected_components
number_strongly_connected_components

Notes
-----
This function is for undirected graphs only. For directed graphs, use
:func:`strongly_connected_components` or
:func:`weakly_connected_components`.

The algorithm is based on a Breadth-First Search (BFS) traversal and its
time complexity is $O(n + m)$, where $n$ is the number of nodes and $m$ the
number of edges in the graph.

N)setlen
_plain_bfsupdate)Gseennvcs   &    f/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/algorithms/components/connected.pyconnected_componentsr      sK     H 5DAA=1#d)mQ/AKKNG	 s
   A7Ac                8    \        R \        V 4       4       4      # )a  Returns the number of connected components.

The connected components of an undirected graph partition the graph into
disjoint sets of nodes. Each of these sets induces a subgraph of graph
`G` that is connected and not part of any larger connected subgraph.

A graph is connected (:func:`is_connected`) if, for every pair of distinct
nodes, there is a path between them. If there is a pair of nodes for
which such path does not exist, the graph is not connected (also referred
to as "disconnected").

A graph consisting of a single node and no edges is connected.
Connectivity is undefined for the null graph (graph with no nodes).

Parameters
----------
G : NetworkX graph
   An undirected graph.

Returns
-------
n : integer
   Number of connected components

Raises
------
NetworkXNotImplemented
    If G is directed.

Examples
--------
>>> G = nx.Graph([(0, 1), (1, 2), (5, 6), (3, 4)])
>>> nx.number_connected_components(G)
3

See Also
--------
connected_components
is_connected
number_weakly_connected_components
number_strongly_connected_components

Notes
-----
This function is for undirected graphs only. For directed graphs, use
:func:`number_strongly_connected_components` or
:func:`number_weakly_connected_components`.

The algorithm is based on a Breadth-First Search (BFS) traversal and its
time complexity is $O(n + m)$, where $n$ is the number of nodes and $m$ the
number of edges in the graph.

c              3   &   "   T F  p^x  K	  	  R# 5i)   N ).0_s   & r   	<genexpr>.number_connected_components.<locals>.<genexpr>   s     21Qq1s   )sumr   )r
   s   &r   number_connected_componentsr   ]   s    p 2.q1222    c                    \        V 4      pV^ 8X  d   \        P                  ! R4      h\        \        \	        V 4      4      4      V8H  # )ar  Returns True if the graph is connected, False otherwise.

A graph is connected if, for every pair of distinct nodes, there is a
path between them. If there is a pair of nodes for which such path does
not exist, the graph is not connected (also referred to as "disconnected").

A graph consisting of a single node and no edges is connected.
Connectivity is undefined for the null graph (graph with no nodes).

Parameters
----------
G : NetworkX Graph
   An undirected graph.

Returns
-------
connected : bool
  True if the graph is connected, False otherwise.

Raises
------
NetworkXNotImplemented
    If G is directed.

Examples
--------
>>> G = nx.path_graph(4)
>>> print(nx.is_connected(G))
True

See Also
--------
is_strongly_connected
is_weakly_connected
is_semiconnected
is_biconnected
connected_components

Notes
-----
This function is for undirected graphs only. For directed graphs, use
:func:`is_strongly_connected` or :func:`is_weakly_connected`.

The algorithm is based on a Breadth-First Search (BFS) traversal and its
time complexity is $O(n + m)$, where $n$ is the number of nodes and $m$ the
number of edges in the graph.

z-Connectivity is undefined for the null graph.)r   nxNetworkXPointlessConceptnextr   r
   r   s   & r   is_connectedr!      sH    f 	AAAv));
 	
 t(+,-22r   c                .    \        V \        V 4      V4      # )a  Returns the set of nodes in the component of graph containing node n.

A connected component is a set of nodes that induces a subgraph of graph
`G` that is connected and not part of any larger connected subgraph.

A graph is connected (:func:`is_connected`) if, for every pair of distinct
nodes, there is a path between them. If there is a pair of nodes for
which such path does not exist, the graph is not connected (also referred
to as "disconnected").

A graph consisting of a single node and no edges is connected.
Connectivity is undefined for the null graph (graph with no nodes).

Parameters
----------
G : NetworkX Graph
   An undirected graph.

n : node label
   A node in G

Returns
-------
comp : set
   A set of nodes in the component of G containing node n.

Raises
------
NetworkXNotImplemented
    If G is directed.

Examples
--------
>>> G = nx.Graph([(0, 1), (1, 2), (5, 6), (3, 4)])
>>> nx.node_connected_component(G, 0)  # nodes of component that contains node 0
{0, 1, 2}

See Also
--------
connected_components

Notes
-----
This function is for undirected graphs only.

The algorithm is based on a Breadth-First Search (BFS) traversal and its
time complexity is $O(n + m)$, where $n$ is the number of nodes and $m$ the
number of edges in the graph.

)r   r   r    s   &&r   node_connected_componentr#      s    j aQ##r   c                    V P                   pV0pV.pV'       d]   Tp. pV FP  pW7,           F-  pW9  g   K  VP                  V4       VP                  V4       K/  	  \        V4      V8X  g   KN  Vu # 	  Kd  V# )zA fast BFS node generator)_adjaddappendr   )	r
   r   sourceadjr   	nextlevel	thislevelr   ws	   &&&      r   r   r     su    
&&C8DI
		AVV=HHQK$$Q'  4yA~  Kr   )r   r   r!   r#   )__doc__networkxr   networkx.utils.decoratorsr   utilsr   __all___dispatchabler   r   r!   r#   r   r   r   r   <module>r3      s      9 & Z H  !HV Z 63  !63r Z 63  !63r Z 3$  !3$lr   