code: def save(self, filename=None, directory=None):
          
          if filename is not None:
              self.filename = filename
          if directory is not None:
              self.directory = directory
  
          filepath = self.filepath
          tools.mkdirs(filepath)
  
          data = text_type(self.source)
  
          with io.open(filepath, 'w', encoding=self.encoding) as fd:
              fd.write(data)
              if not data.endswith(u'\n'):
                  fd.write(u'\n')
  
          return filepath
docs: Save the DOT source to file. Ensure the file ends with a newline.
  
          Args:
              filename: Filename for saving the source (defaults to ``name`` + ``'.gv'``)
              directory: (Sub)directory for source saving and rendering.
          Returns:
              The (possibly relative) path of the saved source file.