code: def export_json(self, filename):
          
          json_graph = self.to_json()
          with open(filename, 'wb') as f:
              f.write(json_graph.encode('utf-8'))
docs: Export graph in JSON form to the given file.