+
    �°³j·  ã                   óÒ   € R t ^ RIt^ RIHt . R
Ot]! ^4      RR l4       tR t]! ^4      RR l4       tR t	]! ^4      RR l4       t
]! ^4      RR l4       t]! ^4      RR	 l4       tR# )zS
Utilities for generating random numbers, random sequences, and
random selections.
N)Úpy_random_statec                ól   € \        V 4       Uu. uF  q2P                  V^,
          4      NK  	  up# u upi )zC
Return sample sequence of length n from a power law distribution.
)ÚrangeÚparetovariate)ÚnÚexponentÚseedÚis   &&& Ú_/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/utils/random_sequence.pyÚpowerlaw_sequencer      s-   € ô
 7<¸A´hÓ?±h°×Ñ˜x¨!�|Ö,±hÑ?Ð?ùÒ?s   Ž 1c                óþ   € \        V 4      p\        V4      p\        V4      p^V,          V,
          ^8w  d   R# V^ .8w  d=   \        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   R# R# )aè  Check if a degree sequence is valid for a tree.

Two conditions must be met for a degree sequence to be valid for a tree:

1. The number of nodes must be one more than the number of edges.
2. The degree sequence must be trivial or have only strictly positive
   node degrees.

Parameters
----------
degree_sequence : iterable
    Iterable of node degrees.

Returns
-------
bool
    Whether the degree sequence is valid for a tree.
str
    Reason for invalidity, or dummy string if valid.
Fc              3   ó*   "  € T F	  q^ 8*  x € K  	  R# 5i)é    N© )Ú.0Úds   & r
   Ú	<genexpr>Ú0is_valid_tree_degree_sequence.<locals>.<genexpr><   s   é € Ð0©C q žF«Cùs   ‚T)Fz1tree must have one more node than number of edges)Fz8nontrivial tree must have strictly positive node degrees)TÚ )ÚlistÚlenÚsumÚany)Údegree_sequenceÚseqÚnumber_of_nodesÚtwice_number_of_edgess   &   r
   Úis_valid_tree_degree_sequencer   !   sn   € ô* ˆÓ
€CÜ˜#“h€OÜ ›HÐàˆ?ÕÐ2Õ2°aÔ7ØIÐIØ	��ŒŸ›Ñ0©CÓ0ŸŸšÑ0©CÓ0×0Ò0ØPÐPØ€Oó    c                ó”  € V^8  d   \        R4      hV ^8:  d   \        R4      hV R,
          p^V,          p RVP                  4       ,
          pVP                  4       p\        WRV,          ) ,          ,          4      pRRV,          ,           V,          pWg,          VR,
          ,          VR,
          ,          W„,          8:  g   K�   V# )aç  Returns a random value chosen from the Zipf distribution.

The return value is an integer drawn from the probability distribution

.. math::

    p(x)=\frac{x^{-\alpha}}{\zeta(\alpha, x_{\min})},

where $\zeta(\alpha, x_{\min})$ is the Hurwitz zeta function.

Parameters
----------
alpha : float
  Exponent value of the distribution
xmin : int
  Minimum value
seed : integer, random_state, or None (default)
    Indicator of random number generation state.
    See :ref:`Randomness<randomness>`.

Returns
-------
x : int
  Random value from Zipf distribution

Raises
------
ValueError:
  If xmin < 1 or
  If alpha <= 1

Notes
-----
The rejection algorithm generates random values for a the power-law
distribution in uniformly bounded expected time dependent on
parameters.  See [1]_ for details on its operation.

Examples
--------
>>> nx.utils.zipf_rv(alpha=2, xmin=3, seed=42)
8

References
----------
.. [1] Luc Devroye, Non-Uniform Random Variate Generation,
   Springer-Verlag, New York, 1986.
zxmin < 1za <= 1.0g      ð?)Ú
ValueErrorÚrandomÚint)	ÚalphaÚxminr   Úa1ÚbÚuÚvÚxÚts	   &&&      r
   Úzipf_rvr+   A   s©   € ðb ˆa„xÜ˜Ó$Ð$Ø�„zÜ˜Ó$Ð$Ø	��€BØ	ˆ2�€AØ
Ø�$—+‘+“-ÕˆØ�K‰K‹MˆÜ�˜c B�h˜KÕ'Õ'Ó(ˆØ�C˜!•G�_ Õ#ˆØ�5�A˜•GÕ  C¥Õ(¨A­EÖ1ØØ€Hr   c                óŠ   € R.pRpV  F  pW#,          pVP                  V4       K  	  V Uu. uF  q3V,          NK  	  up# u upi )zFReturns normalized cumulative distribution from discrete distribution.g        )Úappend)ÚdistributionÚcdfÚ
cumulativeÚelements   &   r
   Úcumulative_distributionr2   ‚   sN   € ð ˆ%€CØ€JÛˆØÕˆ
Ø�
‰
�:Öñ  ñ 14Ó4± W�j× Ð ±Ñ4Ð4ùÒ4s   ¬A c                ó  € ^ RI pVe   TpM&Ve   \        V4      pM\        P                  ! R4      h\	        V 4       Uu. uF  qcP                  4       NK  	  ppV Uu. uF  q„P                  WX4      ^,
          NK  	  p	pV	# u upi u upi )a  
Return sample sequence of length n from a given discrete distribution
or discrete cumulative distribution.

One of the following must be specified.

distribution = histogram of values, will be normalized

cdistribution = normalized discrete cumulative distribution

Nz8discrete_sequence: distribution or cdistribution missing)Úbisectr2   ÚnxÚNetworkXErrorr   r!   Úbisect_left)
r   r.   Úcdistributionr   r4   r/   r	   ÚinputseqÚsr   s
   &&&&      r
   Údiscrete_sequencer;   �   sŒ   € ó àÒ Ø‰Ø	Ò	!Ü% lÓ3‰ä×ÒØFó
ð 	
ô
 (-¨Q¤xÓ0¡x !—‘–¡x€HÐ0ñ 4<Ó
<±8¨a×Ñ˜cÓ%¨×)Ð)±8€CÐ
<Ø€Jùò	 1ùò =s   ¿BÁ Bc                óº   € V\        V 4      8”  d   \        R4      h\        4       p\        V4      V8  d   VP                  \	        W4      4       K,  \        V4      # )zxReturns k items without replacement from a weighted sample.

The input is a dictionary of items with weights as values.
zsample larger than population)r   r    ÚsetÚaddÚweighted_choicer   )ÚmappingÚkr   Úsamples   &&& r
   Úrandom_weighted_samplerC   ­   sI   € ð 	Œ3ˆw‹<ÔÜÐ8Ó9Ð9Ü‹U€FÜ
ˆf‹+˜Œ/Ø�
‰
”? 7Ó1Ö2Ü�‹<Ðr   c                óº   € VP                  4       \        V P                  4       4      ,          pV P                  4        F  w  r4W$,          pV^ 8  g   K  Vu # 	  R# )zmReturns a single element from a weighted sample.

The input is a dictionary of items with weights as values.
N)r!   r   ÚvaluesÚitems)r@   r   ÚrndrA   Úws   &&   r
   r?   r?   »   sE   € ð �+‰+‹-œ#˜gŸn™nÓ.Ó/Õ
/€CØ—‘–‰ˆØ�ˆØ�Ž7ØŠHó  r   )r   r   r+   r2   r;   rC   r?   )g       @N)é   N)NNN)N)Ú__doc__Únetworkxr5   Únetworkx.utilsr   Ú__all__r   r   r+   r2   r;   rC   r?   r   r   r
   Ú<module>rN      s¤   ðñó
 Ý *ò€ñ  �Óó@ó ð@òñ@ �Óó=ó ð=ò@5ñ �Óóó ðñ> �Óó
ó ð
ñ �Óó
ó ò
r   