code: def to_networkx_digraph(H):
      
      import networkx as nx
  
      if not isinstance(H, DirectedHypergraph):
          raise TypeError("Transformation only applicable to \
                          directed hypergraphs")
  
      G = to_graph_decomposition(H)
  
      nx_graph = nx.DiGraph()
  
      for node in G.node_iterator():
          nx_graph.add_node(node, G.get_node_attributes(node))
  
      for hyperedge_id in G.hyperedge_id_iterator():
          tail_node = G.get_hyperedge_tail(hyperedge_id).pop()
          head_node = G.get_hyperedge_head(hyperedge_id).pop()
          edge_attributes = G.get_hyperedge_attributes(hyperedge_id)
          nx_graph.add_edge(tail_node, head_node, edge_attributes)
  
      return nx_graph
docs: Returns a NetworkX DiGraph object that is the graph decomposition of
      the given hypergraph.
      See "to_graph_decomposition()" for more details.
  
      :param H: the hypergraph to decompose into a graph.
      :returns: nx.DiGraph -- NetworkX DiGraph object representing the
              decomposed hypergraph.
      :raises: TypeError -- Transformation only applicable to
              directed hypergraphs