def test_networkxs_to_data_dict_raises_node_key_error(self):
    """If the nodes have keys not consistent with the order they were added."""
    graph_nx = nx.OrderedMultiDiGraph()
    graph_nx.add_node(0, features=None)
    graph_nx.add_node(1, features=None)
    graph_nx.add_node(3, features=None)

    with self.assertRaisesRegexp(
        ValueError, "found node with index 2 and key 3"):
      utils_np.networkx_to_data_dict(graph_nx)

    # Check that it is still raised even if there is a node with each key,
    # and only the order is wrong.
    graph_nx.add_node(2, features=None)
    with self.assertRaisesRegexp(
        ValueError, "found node with index 2 and key 3"):
      utils_np.networkx_to_data_dict(graph_nx)
If the nodes have keys not consistent with the order they were added.
graph_nets/tests/utils_np_test.py