#NEWLINE# def make_graph( self , graph_xml , graphml_keys , defaults ) : #NEWLINE# #INDENT# edgedefault = graph_xml . get ( 'edgedefault' , None ) #NEWLINE# if ( edgedefault == 'directed' ) : #NEWLINE# #INDENT# G = nx . MultiDiGraph ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# G = nx . MultiGraph ( ) #NEWLINE# #UNINDENT# G . graph [ 'node_default' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# G . graph [ 'edge_default' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( key_id , value ) in defaults . items ( ) : #NEWLINE# #INDENT# key_for = graphml_keys [ key_id ] [ 'for' ] #NEWLINE# name = graphml_keys [ key_id ] [ 'name' ] #NEWLINE# python_type = graphml_keys [ key_id ] [ 'type' ] #NEWLINE# if ( key_for == 'node' ) : #NEWLINE# #INDENT# G . graph [ 'node_default' ] . update ( { #NEWLINE# #INDENT# name : python_type ( value ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if ( key_for == 'edge' ) : #NEWLINE# #INDENT# G . graph [ 'edge_default' ] . update ( { #NEWLINE# #INDENT# name : python_type ( value ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# hyperedge = graph_xml . find ( ( '{%s}hyperedge' % self . NS_GRAPHML ) ) #NEWLINE# if ( hyperedge is not None ) : #NEWLINE# #INDENT# raise nx . NetworkXError ( 'GraphML reader does not support hyperedges' ) #NEWLINE# #UNINDENT# for node_xml in graph_xml . findall ( ( '{%s}node' % self . NS_GRAPHML ) ) : #NEWLINE# #INDENT# self . add_node ( G , node_xml , graphml_keys ) #NEWLINE# #UNINDENT# for edge_xml in graph_xml . findall ( ( '{%s}edge' % self . NS_GRAPHML ) ) : #NEWLINE# #INDENT# self . add_edge ( G , edge_xml , graphml_keys ) #NEWLINE# #UNINDENT# data = self . decode_data_elements ( graphml_keys , graph_xml ) #NEWLINE# G . graph . update ( data ) #NEWLINE# if ( not self . multigraph ) : #NEWLINE# #INDENT# if G . is_directed ( ) : #NEWLINE# #INDENT# return nx . DiGraph ( G ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return nx . Graph ( G ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return G