def relabel_node(bg, old_name, new_name):
    """
    Change the name of a node.

    param old_name: The previous name of the node
    param new_name: The new name of the node
    """
    define = bg.defines[old_name]
    del bg.defines[old_name]
    bg.defines[new_name] = define
    edge = bg.edges[old_name]
    del bg.edges[old_name]
    bg.edges[new_name] = edge
    for k in bg.edges.keys():
        new_edges = set()
        for e in bg.edges[k]:
            if e == old_name:
                new_edges.add(new_name)
            else:
                new_edges.add(e)
        bg.edges[k] = new_edges
