def assert_nx_graph_eq(g1, g2):
    """Assertion function for graph equality."""
    assert set(g1.nodes()) == set(g2.nodes())
    assert set(g1.edges()) == set(g2.edges())
    for n in g1.nodes():
        assert g1.node[n] == g2.node[n]
    for e1, e2 in g1.edges():
        assert g1.adj[e1][e2] == g2.adj[e1][e2]
    return
