#NEWLINE# def deserialize( d , **kw ) : #NEWLINE# #INDENT# ( vert_section , edge_section ) = d . split ( '\n#\n' , 1 ) #NEWLINE# verts = [ line . split ( None , 1 ) for line in vert_section . split ( '\n' ) if line ] #NEWLINE# counts = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# edges = [ ] #NEWLINE# for line in edge_section . split ( '\n' ) : #NEWLINE# #INDENT# if line : #NEWLINE# #INDENT# ( fm , to , label ) = ( line . split ( None , 2 ) + [ '' ] ) [ : 3 ] #NEWLINE# c = counts . get ( c , 0 ) #NEWLINE# counts [ label ] = ( c + 1 ) #NEWLINE# id = ( ( '%s-%d' % ( label , c ) ) if c else label ) #NEWLINE# edges . append ( ( id , label , fm , to ) ) #NEWLINE# #UNINDENT# #UNINDENT# return ( verts , edges )