U
    ¹mœd:  ã                   @   s&   d Z dgZddlZejddd„ƒZdS )	z
Ego graph.
Ú	ego_graphé    Né   TFc           	      C   s–   |rB|dk	r(t j|  ¡ |||d�\}}qvtt j|  ¡ ||d�ƒ}n4|dk	rbt j| |||d�\}}ntt j| ||d�ƒ}|  |¡ ¡ }|s’| |¡ |S )aï  Returns induced subgraph of neighbors centered at node n within
    a given radius.

    Parameters
    ----------
    G : graph
      A NetworkX Graph or DiGraph

    n : node
      A single node

    radius : number, optional
      Include all neighbors of distance<=radius from n.

    center : bool, optional
      If False, do not include center node in graph

    undirected : bool, optional
      If True use both in- and out-neighbors of directed graphs.

    distance : key, optional
      Use specified edge data key as distance.  For example, setting
      distance='weight' will use the edge weight to measure the
      distance from the node n.

    Notes
    -----
    For directed graphs D this produces the "out" neighborhood
    or successors.  If you want the neighborhood of predecessors
    first reverse the graph with D.reverse().  If you want both
    directions use the keyword argument undirected=True.

    Node, edge, and graph attributes are copied to the returned subgraph.
    N)ÚcutoffÚweight)r   )ÚnxZsingle_source_dijkstraZto_undirectedÚdictZ"single_source_shortest_path_lengthZsubgraphÚcopyÚremove_node)	ÚGÚnZradiusÚcenterZ
undirectedZdistanceÚspÚ_ÚH© r   úP/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/networkx/generators/ego.pyr   	   s,    $   ÿ  ÿÿ
)r   TFN)Ú__doc__Ú__all__Znetworkxr   Ú	_dispatchr   r   r   r   r   Ú<module>   s   