code: def as_graph(self) -> Digraph:  # pragma: no cover
          
          if Digraph is None:
              raise ImportError('The graphviz package is required to draw the graph.')
          dot = Digraph()
  
          nodes = set()
          queue = [self._root]
          while queue:
              state = queue.pop(0)
              if not state.payload:
                  dot.node('n{!s}'.format(state.id), '', {'shape': ('circle' if state else 'doublecircle')})
              else:
                  dot.node('n{!s}'.format(state.id), '\n'.join(map(str, state.payload)), {'shape': 'box'})
  
              for next_state in state.values():
                  if next_state.id not in nodes:
                      queue.append(next_state)
                      nodes.add(state.id)
  
          nodes = set()
          queue = [self._root]
          while queue:
              state = queue.pop(0)
              if state.id in nodes:
                  continue
              nodes.add(state.id)
  
              for (label, other) in state.items():
                  dot.edge('n{!s}'.format(state.id), 'n{!s}'.format(other.id), _term_str(label))
                  if other.id not in nodes:
                      queue.append(other)
  
          return dot
docs: Renders the discrimination net as graphviz digraph.