code: def to_picture(self, filename):
          
          fileformat = path.splitext(filename)[1][1:]
          with NamedTemporaryFile("wb", delete=False) as dotfile:
              dotfilename = dotfile.name
              for line in self:
                  dotfile.write(("%s\n" % line).encode("utf-8"))
              dotfile.flush()
              cmd = ["dot", dotfilename, "-T", fileformat, "-o", filename]
              check_call(cmd)
          try:
              remove(dotfilename)
          except Exception:  # pragma: no cover
              msg = 'Could not remove temporary file %s' % dotfilename
              logging.getLogger(__name__).warn(msg)
docs: Write graph to a temporary file and invoke `dot`.
  
          The output file type is automatically detected from the file suffix.
  
          *`graphviz` needs to be installed, before usage of this method.*