ó
|£*^c           @   sx   d  Z  d d l m Z d d l Z d d l Z d d l m Z d Z d g Z	 e d ƒ e d ƒ e
 d	 d
 „ ƒ ƒ Z d S(   sR   Functions for generating stochastic graphs from a given weighted directed
graph.

iÿÿÿÿ(   t   divisionN(   t   not_implemented_fors%   Aric Hagberg <aric.hagberg@gmail.com>t   stochastic_grapht
   multigrapht
   undirectedt   weightc         C   s¦   | r t  j |  ƒ } n |  } | j d | ƒ } xo | j d t ƒ D][ \ } } } | | d k r€ t j d | ƒ d | | <qC | j | d ƒ | | | | <qC W| S(   s  Returns a right-stochastic representation of the 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 instance of
      :class:`networkx.Digraph`. 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
      a positive number.

    R   t   datai    s   zero out-degree for node %si   (   t   nxt   DiGrapht
   out_degreet   edgest   Truet   warningst   warnt   get(   t   Gt   copyR   t   Wt   degreet   ut   vt   d(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/stochastic.pyR      s    ""(   t   __doc__t
   __future__R    R   t   networkxR   t   networkx.utilsR   t
   __author__t   __all__R   R   (    (    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/stochastic.pyt   <module>   s   			