ó žÃÒYc@s˜dZddlZddlmZddddgZedƒd „ƒZedƒd „ƒZedƒed „ƒZ edƒd „ƒZ d „Z dS(sWeakly connected components.iÿÿÿÿN(tnot_implemented_fort"number_weakly_connected_componentstweakly_connected_componentst$weakly_connected_component_subgraphstis_weakly_connectedt undirectedccsTtƒ}xD|D]<}||krtt||ƒƒ}|V|j|ƒqqWdS(sÙGenerate weakly connected components of G. Parameters ---------- G : NetworkX graph A directed graph Returns ------- comp : generator of sets A generator of sets of nodes, one for each weakly connected component of G. Raises ------ NetworkXNotImplemented: If G is undirected. Examples -------- Generate a sorted list of weakly connected components, largest first. >>> G = nx.path_graph(4, create_using=nx.DiGraph()) >>> nx.add_path(G, [10, 11, 12]) >>> [len(c) for c in sorted(nx.weakly_connected_components(G), ... key=len, reverse=True)] [4, 3] If you only want the largest component, it's more efficient to use max instead of sort: >>> largest_cc = max(nx.weakly_connected_components(G), key=len) See Also -------- connected_components strongly_connected_components Notes ----- For directed graphs only. N(tsett _plain_bfstupdate(tGtseentvtc((s…/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/components/weakly_connected.pyRs -   cCsttt|ƒƒƒS(séReturn the number of weakly connected components in G. Parameters ---------- G : NetworkX graph A directed graph. Returns ------- n : integer Number of weakly connected components Raises ------ NetworkXNotImplemented: If G is undirected. See Also -------- weakly_connected_components number_connected_components number_strongly_connected_components Notes ----- For directed graphs only. (tlentlistR(R ((s…/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/components/weakly_connected.pyRLsccsFx?t|ƒD]1}|r0|j|ƒjƒVq |j|ƒVq WdS(s§Generate weakly connected components as subgraphs. Parameters ---------- G : NetworkX graph A directed graph. copy: bool (default=True) If True make a copy of the graph attributes Returns ------- comp : generator A generator of graphs, one for each weakly connected component of G. Raises ------ NetworkXNotImplemented: If G is undirected. Examples -------- Generate a sorted list of weakly connected components, largest first. >>> G = nx.path_graph(4, create_using=nx.DiGraph()) >>> nx.add_path(G, [10, 11, 12]) >>> [len(c) for c in sorted(nx.weakly_connected_component_subgraphs(G), ... key=len, reverse=True)] [4, 3] If you only want the largest component, it's more efficient to use max instead of sort: >>> Gc = max(nx.weakly_connected_component_subgraphs(G), key=len) See Also -------- weakly_connected_components strongly_connected_component_subgraphs connected_component_subgraphs Notes ----- For directed graphs only. Graph, node, and edge attributes are copied to the subgraphs by default. N(Rtsubgraphtcopy(R Rtcomp((s…/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/components/weakly_connected.pyRms1cCsJt|ƒdkr$tjdƒ‚nttt|ƒƒdƒt|ƒkS(sTest directed graph for weak connectivity. A directed graph is weakly connected if, and only if, the graph is connected when the direction of the edge between nodes is ignored. Parameters ---------- G : NetworkX Graph A directed graph. Returns ------- connected : bool True if the graph is weakly connected, False otherwise. Raises ------ NetworkXNotImplemented: If G is undirected. See Also -------- is_strongly_connected is_semiconnected is_connected is_biconnected weakly_connected_components Notes ----- For directed graphs only. is-Connectivity is undefined for the null graph.(R tnxtNetworkXPointlessConceptRR(R ((s…/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/components/weakly_connected.pyR¥s# ccs˜|j}|j}tƒ}|h}xm|r“|}tƒ}xQ|D]I}||krC|V|j|ƒ|j||ƒ|j||ƒqCqCWq'WdS(swA fast BFS node generator The direction of the edge between nodes is ignored. For directed graphs only. N(tsucctpredRtaddR(R tsourcetGsucctGpredR t nextlevelt thislevelR ((s…/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/components/weakly_connected.pyRÏs         ( t__doc__tnetworkxRtnetworkx.utils.decoratorsRt__all__RRtTrueRRR(((s…/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/components/weakly_connected.pyt s  5! 7*