Ë
    D^(hŸ  ã                   ó<   — d Z ddlZdgZej                  dd„«       Zy)z@Algorithm to select influential nodes in a graph using VoteRank.é    NÚvoterankc                 ó   ‡— g }i Št        | «      dk(  r|S |�|t        | «      kD  rt        | «      }| j                  «       r-t        d„ | j                  «       D «       «      t        | «      z  }n,t        d„ | j	                  «       D «       «      t        | «      z  }| j                  «       D ]	  }ddg‰|<   Œ t        |«      D �]	  }| j                  «       D ]
  }d‰|   d<   Œ | j                  «       D ]B  \  }}‰|   dxx   ‰|   d   z  cc<   | j                  «       rŒ-‰|   dxx   ‰|   d   z  cc<   ŒD |D ]
  }d‰|   d<   Œ t        | j
                  ˆfd„¬«      }‰|   d   dk(  r|c S |j                  |«       ddg‰|<   | j                  |«      D ]0  \  }}‰|   dxx   d|z  z  cc<   t        ‰|   d   d«      ‰|   d<   Œ2 �Œ |S )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   ó&   K  — | ]	  \  }}|–— Œ y ­w©N© ©Ú.0Ú_Údegs      úi/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/networkx/algorithms/centrality/voterank_alg.pyú	<genexpr>zvoterank.<locals>.<genexpr>@   s   è ø€ Ò9¡  3œÑ9ùó   ‚c              3   ó&   K  — | ]	  \  }}|–— Œ y ­wr   r   r   s      r   r   zvoterank.<locals>.<genexpr>C   s   è ø€ Ò5¡  3œÑ5ùr   é   c                 ó   •— ‰|    d   S )Nr   r   )ÚxÚ	vote_ranks    €r   ú<lambda>z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ò 	5‰FˆAˆsà�a‰L˜‹O˜y¨™~¨aÑ0Ñ0‹OØ—=‘=•?Ø˜#‘˜qÓ! Y¨q¡\°!¡_Ñ4Ô!ð		5ð
 #ò 	 ˆAØˆI�a‰L˜ŠOð	 ô �—‘Ó6Ô7ˆØ�Q‰<˜‰?˜aÒØ$Ò$Ø× Ñ  Ô#à˜1�vˆ	�!‰à—g‘g˜a“jò 	:‰FˆAˆsØ�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   