Adds the ID of each node of a discourse graph as a label (an attribute
    named ``label`` with the value of the node ID) to itself. This will
    ignore nodes whose ID isn't a string or which already have a label
    attribute.

    Parameters
    ----------
    discoursegraph : DiscourseDocumentGraph

def add_node_ids_as_labels(discoursegraph):
    """
    Adds the ID of each node of a discourse graph as a label (an attribute
    named ``label`` with the value of the node ID) to itself. This will
    ignore nodes whose ID isn't a string or which already have a label
    attribute.

    Parameters
    ----------
    discoursegraph : DiscourseDocumentGraph
    """
    for node_id, properties in discoursegraph.nodes_iter(data=True):
        if 'label' not in properties and isinstance(node_id, (str, unicode)):
            discoursegraph.node[node_id]['label'] = ensure_utf8(node_id)