ó
    …~iŸ  ã                   ó>   • S r SSKrS/r\R                  SS j5       rg)z@Algorithm to select influential nodes in a graph using VoteRank.é    NÚvoterankc                 óÎ  ^• / n0 m[        U 5      S:X  a  U$ Ub  U[        U 5      :”  a  [        U 5      nU R                  5       (       a-  [        S U R                  5        5       5      [        U 5      -  nO,[        S U R	                  5        5       5      [        U 5      -  nU R                  5        H
  nSS/TU'   M     [        U5       GH  nU R                  5        H  nSTU   S'   M     U R                  5        HH  u  pFTU   S==   TU   S   -  ss'   U R                  5       (       a  M2  TU   S==   TU   S   -  ss'   MJ     U H  nSTU   S'   M     [        U R
                  U4S jS9nTU   S   S:X  a  Us  $ UR                  U5        SS/TU'   U R                  U5       H0  u  pVTU   S==   SU-  -  ss'   [        TU   S   S5      TU   S'   M2     GM     U$ )a#  Select a list of influential nodes in a graph using VoteRank algorithm

VoteRank [1]_ computes a ranking of the nodes in a graph G based on a
voting scheme. With VoteRank, all nodes vote for each of its in-neighbors
and the node with the highest votes is elected iteratively. The voting
ability of out-neighbors of elected nodes is decreased in subsequent turns.

Parameters
----------
G : graph
    A NetworkX graph.

number_of_nodes : integer, optional
    Number of ranked nodes to extract (default all nodes).

Returns
-------
voterank : list
    Ordered list of computed seeds.
    Only nodes with positive number of votes are returned.

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

The algorithm can be used both for undirected and directed graphs.
However, the directed version is different in two ways:
(i) nodes only vote for their in-neighbors and
(ii) only the voting ability of elected node and its out-neighbors are updated:

>>> G = nx.DiGraph([(0, 1), (2, 1), (2, 3), (3, 4)])
>>> nx.voterank(G)
[2, 3]

Notes
-----
Each edge is treated independently in case of multigraphs.

References
----------
.. [1] Zhang, J.-X. et al. (2016).
    Identifying a set of influential spreaders in complex networks.
    Sci. Rep. 6, 27823; doi: 10.1038/srep27823.
r   c              3   ó*   #   • U  H	  u  pUv •  M     g 7f©N© ©Ú.0Ú_Údegs      Úh/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/algorithms/centrality/voterank_alg.pyÚ	<genexpr>Úvoterank.<locals>.<genexpr>@   s   é € Ð9ª.¡ �ª.ùó   ‚c              3   ó*   #   • U  H	  u  pUv •  M     g 7fr   r   r   s      r   r   r   C   s   é € Ð5ª*¡ �ª*ùr   é   c                 ó   >• TU    S   $ )Nr   r   )ÚxÚ	vote_ranks    €r   Ú<lambda>Úvoterank.<locals>.<lambda>U   s   ø€  y°¡|°A¢ó    )Úkey)
ÚlenÚis_directedÚsumÚ
out_degreeÚdegreeÚnodesÚrangeÚedgesÚmaxÚappend)ÚGÚnumber_of_nodesÚinfluential_nodesÚ	avgDegreeÚnr
   Únbrr   s          @r   r   r      s×  ø€ ð` ÐØ€IÜ
ˆ1ƒv�ƒ{Ø Ð ØÑ /´C¸³FÓ":Ü˜a›&ˆØ‡}�}‡�äÑ9¨!¯,©,¬.Ó9Ó9¼CÀ»FÑB‰	ô Ñ5¨!¯(©(¬*Ó5Ó5¼¸A»Ñ>ˆ	à�W‰WŽYˆØ˜1�vˆ	�!‹ñ ô �?×#ˆà—‘–ˆAØˆI�a‰L˜‹Oñ ð —g‘g–i‰FˆAà�a‰L˜‹O˜y¨™~¨aÑ0Ñ0‹OØ—=‘=—?“?Ø˜#‘˜qÓ! Y¨q¡\°!¡_Ñ4Õ!ñ	  ó
 #ˆAØˆI�a‰L˜‹Oñ #ô �—‘Ô6Ñ7ˆØ�Q‰<˜‰?˜aÓØ$Ò$Ø× Ñ  Ô#à˜1�vˆ	�!‰à—g‘g˜a–j‰FˆAØ�c‰N˜1Ó  Y¡Ñ.ÓÜ # I¨c¡N°1Ñ$5°qÓ 9ˆI�c‰N˜1Óô !ñ) $ð. Ðr   r   )Ú__doc__ÚnetworkxÚnxÚ__all__Ú_dispatchabler   r   r   r   Ú<module>r.      s.   ðÙ Fã àˆ,€ð ×ÑóVó ñVr   