def to_networkx_graph(H):
    """Returns a NetworkX Graph object that is the graph decomposition of
    the given H.
    See "to_graph_decomposition()" for more details.

    :param H: the H to decompose into a graph.
    :returns: nx.Graph -- NetworkX Graph object representing the
            decomposed H.
    :raises: TypeError -- Transformation only applicable to
            undirected Hs

    """
    import networkx as nx

    if not isinstance(H, UndirectedHypergraph):
        raise TypeError("Transformation only applicable to \
                        undirected Hs")

    G = to_graph_decomposition(H)

    nx_graph = nx.Graph()

    for node in G.node_iterator():
        nx_graph.add_node(node, G.get_node_attributes(node))

    for hyperedge_id in G.hyperedge_id_iterator():
        edge_nodes = G.get_hyperedge_nodes(hyperedge_id)
        edge_attributes = G.get_hyperedge_attributes(hyperedge_id)
        nx_graph.add_edge(edge_nodes[0], edge_nodes[1], edge_attributes)

    return nx_graph
Returns a NetworkX Graph object that is the graph decomposition of
    the given H.
    See "to_graph_decomposition()" for more details.

    :param H: the H to decompose into a graph.
    :returns: nx.Graph -- NetworkX Graph object representing the
            decomposed H.
    :raises: TypeError -- Transformation only applicable to
            undirected Hs