ó
    …~i'  ã                   ó²   • S r SSKrSSKJr  SSKJr  SS/r\" SS	5      \R                  SS
 j5       5       rS r	\" SS	5      \R                  S 5       5       r
g)z8Algorithms to calculate reciprocity in a directed graph.é    N)ÚNetworkXErroré   )Únot_implemented_forÚreciprocityÚoverall_reciprocityÚ
undirectedÚ
multigraphc                 óž   • Uc  [        U 5      $ X;   a'  [        [        X5      5      S   nUc  [        S5      eU$ [	        [        X5      5      $ )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      Ú\/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/algorithms/reciprocity.pyr   r      s\   € ðB �}Ü" 1Ó%Ð%ð ƒzÜÔ,¨QÓ6Ó7¸Ñ:ˆØÑÜÐ AÓBÐBàÐô Ô! !Ó+Ó,Ð,ó    c              #   ó&  #   • U R                  U5      nU Hv  n[        U R                  U5      5      n[        U R                  U5      5      nXE-  n[	        U5      [	        U5      -   nUS:X  a  US4v •  M`  S[	        U5      -  U-  nX84v •  Mx     g7f)z*Return an iterator of (node, reciprocity).r   Nr   )Ú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Ñ4ˆKØÐ%Ô%ò ùs   ‚BBc                 ó’   • U R                  5       nXR                  5       R                  5       -
  S-  nUS:X  a  [        S5      eX!-  $ )z“Compute the reciprocity for the whole graph.

See the doc of reciprocity for the definition.

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

r   r   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È!ÑK€Nà�QƒÜÐ:Ó;Ð;àÑ&Ð&r   )N)Ú__doc__ÚnetworkxÚnxr   Úutilsr   Ú__all__Ú_dispatchabler   r   r   © r   r   Ú<module>r+      st   ðÙ >ã Ý "å 'àÐ/Ð
0€ñ �\ <Ó0Ø×Ñó--ó ó 1ð--ò`&ñ$ �\ <Ó0Ø×Ññ'ó ó 1ñ'r   