
    h                         S r SSKrSSKJrJr  SSKJr  S/r\" S5      \R                  " SSS	0S
S9SS j5       5       r
g)zRFunctions for generating stochastic graphs from a given weighted directed
graph.

    N)DiGraphMultiDiGraph)not_implemented_forstochastic_graph
undirectedweightznot copy   T)
edge_attrsmutates_inputreturns_graphc                 F   U(       a+  U R                  5       (       a  [        U 5      O
[        U 5      n [        U R	                  US95      nU R                  SS9 H-  u  pEnX4   S:X  a  SXb'   M  UR                  US5      X4   -  Xb'   M/     [        R                  " U 5        U $ )a  Returns a right-stochastic representation of directed graph `G`.

A right-stochastic graph is a weighted digraph in which for each
node, the sum of the weights of all the out-edges of that node is
1. If the graph is already weighted (for example, via a 'weight'
edge attribute), the reweighting takes that into account.

Parameters
----------
G : directed graph
    A :class:`~networkx.DiGraph` or :class:`~networkx.MultiDiGraph`.

copy : boolean, optional
    If this is True, then this function returns a new graph with
    the stochastic reweighting. Otherwise, the original graph is
    modified in-place (and also returned, for convenience).

weight : edge attribute key (optional, default='weight')
    Edge attribute key used for reading the existing weight and
    setting the new weight.  If no attribute with this key is found
    for an edge, then the edge weight is assumed to be 1. If an edge
    has a weight, it must be a positive number.

)r   T)datar   r	   )	is_multigraphr   r   dict
out_degreeedgesgetnx_clear_cache)Gcopyr   degreeuvds          P/var/www/html/env/lib/python3.13/site-packages/networkx/generators/stochastic.pyr   r      s    :  00LOgaj !,,f,-.F777%a9>AIfa(694AI	 &
 OOAH    )Tr   )__doc__networkxr   networkx.classesr   r   networkx.utilsr   __all___dispatchabler    r   r   <module>r%      sT   
  2 .
 \"
Ad% #%r   