Append the specified electrode to the route.

        The route is not modified (i.e., electrode is not appended) if
        electrode is not connected to the last electrode in the existing route.

        Parameters
        ----------
        electrode_id : str
            Electrode identifier.

def append(self, electrode_id):
        '''
        Append the specified electrode to the route.

        The route is not modified (i.e., electrode is not appended) if
        electrode is not connected to the last electrode in the existing route.

        Parameters
        ----------
        electrode_id : str
            Electrode identifier.
        '''
        do_append = False

        if not self.electrode_ids:
            do_append = True
        elif self.device.shape_indexes.shape[0] > 0:
            source = self.electrode_ids[-1]
            target = electrode_id
            if not (source == target):
                source_id, target_id = self.device.shape_indexes[[source,
                                                                  target]]
                try:
                    if self.device.adjacency_matrix[source_id, target_id]:
                        # Electrodes are connected, so append target to current
                        # route.
                        do_append = True
                except IndexError:
                    logger.warning('Electrodes `%s` and `%s` are not '
                                   'connected.', source, target)

        if do_append:
            self.electrode_ids.append(electrode_id)
        return do_append