docs: def display(self, highlight = None, basename = 'graph', format = 'png',
                  pause = True):
          '''
          API:
              display(self, highlight = None, basename = 'graph', format = 'png',
                  pause = True)
          Description:
              Displays graph according to the arguments provided.
              Current display modes: 'off', 'file', 'pygame', 'PIL', 'xdot',
              'svg'
              Current layout modes: Layouts provided by graphviz ('dot', 'fdp',
              'circo', etc.) and 'dot2tex'.
              Current formats: Formats provided by graphviz ('ps', 'pdf', 'png',
              etc.)
          Input:
              highlight: List of nodes to be highlighted.
              basename: File name. It will be used if display mode is 'file'.
              format: Image format, all format supported by Dot are wellcome.
              pause: If display is 'pygame' and pause is True pygame will pause
              and wait for user input before closing the display. It will close
              display window straightaway otherwise.
          Post:
              A display window will pop up or a file will be written depending
              on display mode.
          '''
          if self.attr['display'] == 'off':
              return
          if highlight != None:
              for n in highlight:
                  if not isinstance(n, Node):
                      n = self.get_node(n)
                  n.set_attr('color', 'red')
          if self.get_layout() == 'dot2tex':
              if self.attr['display'] != 'file':
                  self.attr['display'] = 'file'
                  print("Warning: Dot2tex layout can only be used with display mode 'file'")
                  print("         Automatically changing setting")
          if self.attr['display'] == 'file':
              if self.get_layout() == 'dot2tex':
                  try:
                      if DOT2TEX_INSTALLED:
                          if format != 'pdf' or format != 'ps':
                              print("Dot2tex only supports pdf and ps formats, falling back to pdf")
                              format = 'pdf'
                          self.set_layout('dot')
                          tex = dot2tex.dot2tex(self.to_string(), autosize=True, texmode = 'math', template = DOT2TEX_TEMPLATE)
                      else:
                          print("Error: Dot2tex not installed.")
                  except:
                      try:
                          self.set_layout('dot')
                          self.write(basename+'.dot', self.get_layout(), 'dot')
                          sp = subprocess.Popen('dot2tex -t math ' + basename + '.dot', stdout = subprocess.PIPE, 
                                                stderr = subprocess.STDOUT)
                          tex = sp.communicate()[0]
                      except:
                          print("There was an error running dot2tex.")
                  f = open(basename+'.tex', 'w')
                  f.write(tex)
                  f.close()
                  try: 
                      subprocess.call(['latex', basename])
                      if format == 'ps':
                          subprocess.call(['dvips', basename])
                      elif format == 'pdf':
                          subprocess.call(['pdflatex', basename])
                      self.set_layout('dot2tex')
                  except:
                      print("There was an error runing latex. Is it installed?")
              else:
                  self.write(basename+'.'+format, self.get_layout(), format)
              return
          elif self.attr['display'] == 'pygame':
              output = self.create(self.get_layout(), format)
              if output is not None:
                  im = io.StringIO(self.create(self.get_layout(), format))
                  picture = pygame.image.load(im, format)
                  screen = pygame.display.set_mode(picture.get_size())
                  screen.blit(picture, picture.get_rect())
                  pygame.display.flip()
                  while pause:
                      e = pygame.event.poll()
                      if e.type == pygame.KEYDOWN:
                          break
                      if e.type == pygame.QUIT:
                          pause = False
                          pygame.display.quit()
                          # sys.exit() exits the whole program and I (aykut) guess it is
                          # not appropriate here.
                          #sys.exit()
              else:
                  print('Error in displaying graph. Display disabled')
                  self.set_display_mode('off')
          elif self.attr['display'] == 'PIL':
              im = io.StringIO(self.create(self.get_layout(), format))
              if PIL_INSTALLED:
                  im2 = PIL_Image.open(im)
                  im2.show()
              else:
                  print('Error: PIL not installed. Display disabled.')
                  self.attr['display'] = 'off'
          elif self.attr['display'] == 'xdot':
              if XDOT_INSTALLED:
                  window = xdot.DotWindow()
                  window.set_dotcode(self.to_string())
                  window.connect('destroy', gtk.main_quit)
                  gtk.main()
              else:
                  print('Error: xdot not installed. Display disabled.')
                  self.attr['display'] = 'off'
          elif self.attr['display'] == 'svg':
              if not ETREE_INSTALLED:
                  print('Error: etree not installed (display mode: svg). Display disabled.')
                  self.attr['display'] = 'off'
          else:
              print("Unknown display mode: ", end=' ')
              print(self.attr['display'])
          if highlight != None:
              for n in highlight:
                  if not isinstance(n, Node):
                      n = self.get_node(n)
                  n.set_attr('color', 'black')