def _format_label(label_def, label_dot_format):
    """Format state/edge labels, which pop-up on mouse hover.
    """
    s = '"\\n\\n" +'
    for sublabel_name in label_def:
        shown_name = label_dot_format[sublabel_name]
        kv_sep = label_dot_format['type?label']
        sep = label_dot_format['separator']

        s += '"' +shown_name +kv_sep +'" '
        s += '+d.' +str(sublabel_name) +'+"' +sep+'" +'
    s += '" ";'

    return s