code: def as_graph(self) -> Digraph:  # pragma: no cover
          
          if Digraph is None:
              raise ImportError('The graphviz package is required to draw the graph.')
          graph = Digraph()
  
          subgraphs = [Digraph(graph_attr={'rank': 'same'}), Digraph(graph_attr={'rank': 'same'})]
          nodes = [{}, {}]  # type: List[Dict[Union[TLeft, TRight], str]]
          edges = []  # type: List [Tuple[str, str]]
          node_id = 0
          for (tail_part, tail), head_set in self.items():
              if tail not in nodes[tail_part]:
                  name = 'node{:d}'.format(node_id)
                  nodes[tail_part][tail] = name
                  subgraphs[tail_part].node(name, label=str(tail))
                  node_id += 1
              for head_part, head in head_set:
                  if head not in nodes[head_part]:
                      name = 'node{:d}'.format(node_id)
                      nodes[head_part][head] = name
                      subgraphs[head_part].node(name, label=str(head))
                      node_id += 1
                  edges.append((nodes[tail_part][tail], nodes[head_part][head]))
          graph.subgraph(subgraphs[0])
          graph.subgraph(subgraphs[1])
          for tail_node, head_node in edges:
              graph.edge(tail_node, head_node)
          return graph
docs: Returns a :class:`graphviz.Digraph` representation of this directed match graph.