function obj = subgraph( obj,idxcompts )

idxcompts = unique(idxcompts);

newgraph = obj;
newgraph.m_adjmat_comp2comp = obj.m_adjmat_comp2comp(idxcompts,idxcompts);
newgraph.m_adjmat_comp2sample = obj.m_adjmat_comp2sample(idxcompts,:);
if ~isempty(obj.m_adjmat_comp2sample_fullcover)
    newgraph.m_adjmat_comp2sample_fullcover = obj.m_adjmat_comp2sample_fullcover(idxcompts,:);
end
if ~isempty(obj.m_adjmat_comp2sample_justenough)
    newgraph.m_adjmat_comp2sample_justenough = obj.m_adjmat_comp2sample_justenough(idxcompts,:);
end
if ~isempty(obj.m_adjmat_invalid_comp2comp)
    newgraph.m_adjmat_invalid_comp2comp = obj.m_adjmat_invalid_comp2comp(idxcompts,idxcompts);
end
newgraph.m_complabels = obj.m_complabels(idxcompts);
newgraph.m_compscores = obj.m_compscores(idxcompts);
newgraph.m_compts = obj.m_compts(:,idxcompts);
newgraph.m_dftransmat_per_compts = obj.m_dftransmat_per_compts(idxcompts);
newgraph.m_samplepts = obj.m_samplepts;
newgraph.m_sketchimg = obj.m_sketchimg;
if ~isempty(obj.m_conflictscore_comp2comp)
    newgraph.m_conflictscore_comp2comp = obj.m_conflictscore_comp2comp(idxcompts,idxcompts);
end
if ~isempty(obj.m_mergeprobs_comp2comp)
    newgraph.m_mergeprobs_comp2comp = obj.m_mergeprobs_comp2comp(idxcompts,idxcompts);
end
if ~isempty(obj.m_overlapcost_comp2comp)
    newgraph.m_overlapcost_comp2comp = obj.m_overlapcost_comp2comp(idxcompts,idxcompts);
end
newgraph.m_segid_per_compts = obj.m_segid_per_compts(:,idxcompts);
if ~isempty(obj.m_structscore_comp2comp)
    newgraph.m_structscore_comp2comp = obj.m_structscore_comp2comp(idxcompts,idxcompts);
end
if ~isempty(obj.m_symscore_comp2comp)
    newgraph.m_symscore_comp2comp = obj.m_symscore_comp2comp(idxcompts,idxcompts);
end
if ~isempty(obj.m_symask_comp2comp)
    newgraph.m_symask_comp2comp = obj.m_symask_comp2comp(idxcompts,idxcompts);
end
if ~isempty(obj.m_connectable_by_label_comp2comp)
    newgraph.m_connectable_by_label_comp2comp = obj.m_connectable_by_label_comp2comp(idxcompts,idxcompts);
end
if ~isempty(obj.m_movedist_comp2comp)
    newgraph.m_movedist_comp2comp = obj.m_movedist_comp2comp(idxcompts,idxcompts);
end
if ~isempty(obj.m_structscore_comp2comp_raw)
    newgraph.m_structscore_comp2comp_raw = obj.m_structscore_comp2comp_raw(idxcompts,idxcompts);
end
if ~isempty(obj.m_conflict_seg2seg2comp)
    newgraph.m_conflict_seg2seg2comp = obj.m_conflict_seg2seg2comp(:,:,idxcompts);
end
if ~isempty(obj.m_coverlen_seg2comp)
    newgraph.m_coverlen_seg2comp = obj.m_coverlen_seg2comp(:,idxcompts);
end
if ~isempty(obj.m_coverfitness_seg2comp)
    newgraph.m_coverfitness_seg2comp = obj.m_coverfitness_seg2comp(:,idxcompts);
end

newgraph.m_idxcompts_supergraph = idxcompts;
if ~isempty(obj.m_idxcandpivot_in_sketchdata)
    newgraph.m_idxcandpivot_in_sketchdata = obj.m_idxcandpivot_in_sketchdata(idxcompts);
else
    newgraph.m_idxcandpivot_in_sketchdata = idxcompts;
end

newgraph.m_compscores_coverage = obj.m_compscores_coverage(idxcompts);
newgraph.m_compscores_dist2 = obj.m_compscores_dist2(idxcompts);
newgraph.m_compscores_label_context = obj.m_compscores_label_context(idxcompts);
newgraph.m_compscores_ldir_context = obj.m_compscores_ldir_context(idxcompts);

% newgraph.m_symplane_p0 = obj.m_symplane_p0;
% newgraph.m_symplane_normal = obj.m_symplane_normal;
% newgraph.m_likelihood_sample2label = obj.m_likelihood_sample2label;
% newgraph.m_pixgroup_curve_sample2sample = obj.m_pixgroup_curve_sample2sample;
% newgraph.m_pixgroup_parallel_sample2sample = obj.m_pixgroup_parallel_sample2sample;
obj = newgraph;

end

