code: def to_networkx_graph(self, node_attribute_name='bias', edge_attribute_name='bias'):
          
          import networkx as nx
  
          BQM = nx.Graph()
  
          # add the linear biases
          BQM.add_nodes_from(((v, {node_attribute_name: bias, 'vartype': self.vartype})
                              for v, bias in iteritems(self.linear)))
  
          # add the quadratic biases
          BQM.add_edges_from(((u, v, {edge_attribute_name: bias}) for (u, v), bias in iteritems(self.quadratic)))
  
          # set the offset and vartype properties for the graph
          BQM.offset = self.offset
          BQM.vartype = self.vartype
  
          return BQM
docs: Convert a binary quadratic model to NetworkX graph format.
  
          Args:
              node_attribute_name (hashable, optional, default='bias'):
                  Attribute name for linear biases.
  
              edge_attribute_name (hashable, optional, default='bias'):
                  Attribute name for quadratic biases.
  
          Returns:
              :class:`networkx.Graph`: A NetworkX graph with biases stored as
              node/edge attributes.
  
          Examples:
              This example converts a binary quadratic model to a NetworkX graph, using first
              the default attribute name for quadratic biases then "weight".
  
              >>> import networkx as nx
              >>> bqm = dimod.BinaryQuadraticModel({0: 1, 1: -1, 2: .5},
              ...                                  {(0, 1): .5, (1, 2): 1.5},
              ...                                  1.4,
              ...                                  dimod.SPIN)
              >>> BQM = bqm.to_networkx_graph()
              >>> BQM[0][1]['bias']
              0.5
              >>> BQM.node[0]['bias']
              1
              >>> BQM_w = bqm.to_networkx_graph(edge_attribute_name='weight')
              >>> BQM_w[0][1]['weight']
              0.5