def label_graph_ann(G, coords_df, exclude_last=False):
    """Labels the annotator associated with each node in the graph

    Args:
        G (networkx.Graph): Graph with edges indicating clusters of points
            assumed to be derived from the same ground truth detection
        coords_df (DataFrame): Data frame with columns 'x' and 'y' which encode the
            spot locations and 'Algorithm' which encodes the algorithm that
            corresponds with that spot
        exclude_last (bool): Only set as True to exclude a point that has been
            included for the purpose of normalization

    Returns:
        networkx.Graph: Labeled graph
    """

    G_new = G.copy()
    algs = coords_df.Algorithm.unique()
    num_spots = [len(coords_df.loc[coords_df['Algorithm'] == alg]) for alg in algs]

    # Create list of annotator labels
    labels = []
    for i in range(len(num_spots)):
        labels.extend([i] * num_spots[i])

    nodes = list(G_new.nodes)

    if exclude_last:
        for i in range(len(nodes) - 1):
            G_new.nodes[i]['name'] = labels[i]
    else:
        for i in range(len(nodes)):
            G_new.nodes[i]['name'] = labels[i]

    return G_new