#NEWLINE# def test_stochastic( ) : #NEWLINE# #INDENT# G = nx . DiGraph ( ) #NEWLINE# G . add_edge ( 0 , 1 ) #NEWLINE# G . add_edge ( 0 , 2 ) #NEWLINE# S = nx . stochastic_graph ( G ) #NEWLINE# assert_true ( nx . is_isomorphic ( G , S ) ) #NEWLINE# assert_equal ( sorted ( S . edges ( data = True ) ) , [ ( 0 , 1 , { #NEWLINE# #INDENT# 'weight' : 0.5 , #NEWLINE# #UNINDENT# } ) , ( 0 , 2 , { #NEWLINE# #INDENT# 'weight' : 0.5 , #NEWLINE# #UNINDENT# } ) ] ) #NEWLINE# S = nx . stochastic_graph ( G , copy = True ) #NEWLINE# assert_equal ( sorted ( S . edges ( data = True ) ) , [ ( 0 , 1 , { #NEWLINE# #INDENT# 'weight' : 0.5 , #NEWLINE# #UNINDENT# } ) , ( 0 , 2 , { #NEWLINE# #INDENT# 'weight' : 0.5 , #NEWLINE# #UNINDENT# } ) ] )