+
    )i                         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   &&& \/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/utils/random_sequence.pypowerlaw_sequencer      s-    
 7<Ah?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     0CqFCs   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#hOH?22a7II	0C00C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 ax$$z$$	B	2A
$++-KKMcBhK''(C!G_#5AGC(AE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Wj  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  qP                  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
 	

 (-Qx0x!xH0 4<
<8ac%))8C
<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     	3w<899UF
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     ++-#gnn./
/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   