def keep_vertices(self, indices_to_keep, ret_kept_edges=False):
        '''
        Keep the given vertices and discard the others, and any edges to which
        they may belong.


        If `ret_kept_edges` is `True`, return the original indices of the kept
        edges. Otherwise return `self` for chaining.

        '''

        if self.v is None:
            return

        initial_num_verts = self.v.shape[0]
        if self.e is not None:
            initial_num_edges = self.e.shape[0]
            e_indices_to_keep = self.all_edges_with_verts(indices_to_keep, as_boolean=True)

        self.v = self.v[indices_to_keep]
        if self.e is not None:
            v_old_to_new = np.zeros(initial_num_verts, dtype=int)
            e_old_to_new = np.zeros(initial_num_edges, dtype=int)

            v_old_to_new[indices_to_keep] = np.arange(len(indices_to_keep), dtype=int)
            self.e = v_old_to_new[self.e[e_indices_to_keep]]
            e_old_to_new[e_indices_to_keep] = np.arange(self.e.shape[0], dtype=int)
        else:
            e_indices_to_keep = []

        return np.nonzero(e_indices_to_keep)[0] if ret_kept_edges else self
Keep the given vertices and discard the others, and any edges to which
        they may belong.


        If `ret_kept_edges` is `True`, return the original indices of the kept
        edges. Otherwise return `self` for chaining.