def get_connection_index(connection, terminal, d):
    """
    Find if the connection 'C' lies on the edge 'A'-'B', on the edge end 'A' or
    on the edge end 'B' and return the associted connection index.

    Parameters
    ----------
    connection: Series
        Row of the dataframe *connections* obtained from the function
        *dhd.connect.second_selection*.
    terminal: Series
        Row of the dataframe *terminals*.
    d: dict
        Dictionary of the distances between the connection and the edge ends.

    Returns
    -------
    bool
        True if 'C' lies on 'A'-'B', False otherwise.
    str
        Index of the connection 'C': index of 'A' if 'C'='A', index of 'B' if
        'C'='B', concatenation of the *terminal* index and the *connection*
        index otherwise.
    """
    if d['A'] == 0:
        idC = connection['idA']
        on_edge = False
    elif d['B'] == 0:
        idC = connection['idB']
        on_edge = False
    else:
        idC = '{}_{}'.format(terminal.name, connection.name)
        on_edge = True
    return on_edge, idC
