<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from functools import partial <EOL> from networkx . classes import DiGraph <EOL> from networkx . classes import MultiDiGraph <EOL> from networkx . utils import not_implemented_for <EOL> __author__ = "<STR_LIT>" <EOL> __all__ = [ '<STR_LIT>' ] <EOL> @ not_implemented_for ( '<STR_LIT>' ) <EOL> def stochastic_graph ( G , copy = True , weight = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if copy : <EOL> G = MultiDiGraph ( G ) if G . is_multigraph ( ) else DiGraph ( G ) <EOL> degree = dict ( G . out_degree ( weight = weight ) ) <EOL> for u , v , d in G . edges ( data = True ) : <EOL> if degree [ u ] == <NUM_LIT:0> : <EOL> d [ weight ] = <NUM_LIT:0> <EOL> else : <EOL> d [ weight ] = d . get ( weight , <NUM_LIT:1> ) / degree [ u ] <EOL> return G </s>
