+
    )i'                         R t ^ RIt^ RIHt ^RIHt RR.t]! RR4      ]P                  RR l4       4       tR	 t	]! RR4      ]P                  R
 4       4       t
R# )z8Algorithms to calculate reciprocity in a directed graph.N)NetworkXError)not_implemented_forreciprocityoverall_reciprocity
undirected
multigraphc                    Vf   \        V 4      # W9   d-   \        \        W4      4      ^,          pVf   \        R4      hV# \	        \        W4      4      # )a  Compute the reciprocity in a directed graph.

The reciprocity of a directed graph is defined as the ratio
of the number of edges pointing in both directions to the total
number of edges in the graph.
Formally, $r = |{(u,v) \in G|(v,u) \in G}| / |{(u,v) \in G}|$.

The reciprocity of a single node u is defined similarly,
it is the ratio of the number of edges in both directions to
the total number of edges attached to node u.

Parameters
----------
G : graph
   A networkx directed graph
nodes : container of nodes, optional (default=whole graph)
   Compute reciprocity for nodes in this container.

Returns
-------
out : dictionary
   Reciprocity keyed by node label.

Notes
-----
The reciprocity is not defined for isolated nodes.
In such cases this function will return None.

zNot defined for isolated nodes.)r   next_reciprocity_iterr   dict)Gnodesr   s   && ]/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/algorithms/reciprocity.pyr   r      s\    B }"1%% z,Q67: ABB !!+,,    c              #  J  "   V P                  V4      pV F  p\        V P                  V4      4      p\        V P                  V4      4      pWE,          p\	        V4      \	        V4      ,           pV^ 8X  d	   VR3x  Ki  ^\	        V4      ,          V,          pW83x  K  	  R# 5i)z*Return an iterator of (node, reciprocity).N)nbunch_itersetpredecessors
successorslen)	r   r   nnodepredsuccoverlapn_totalr   s	   &&       r   r
   r
   =   s     	eA1>>$'(1<<%&+d)c$i' a<,c'l*W4K%% s   B!B#c                    V P                  4       pWP                  4       P                  4       ,
          ^,          pV^ 8X  d   \        R4      hW!,          # )zCompute the reciprocity for the whole graph.

See the doc of reciprocity for the definition.

Parameters
----------
G : graph
   A networkx graph

zNot defined for empty graphs)number_of_edgesto_undirectedr   )r   
n_all_edgen_overlap_edges   &  r   r   r   O   sK     ""$J ??#4#D#D#FF!KNQ:;;&&r   )N)__doc__networkxnxr   utilsr   __all___dispatchabler   r
   r    r   r   <module>r(      st    >  " '/
0 \<0--  1--`&$ \<0'  1'r   