Large disjoint subgraphs with the same order and size

For a graph G let f(G) be the largest integer k such that there are two vertex-disjoint subgraphs of G, each with k vertices, and that induce the same number of edges. Clearly f(G)≤⌊n/2⌋ but this is not always achievable. Our main result is that for any fixed α>0, if G has n vertices and at most n2-α edges, then f(G)=n/2-o(n), which is asymptotically optimal. The proof also yields a polynomial time randomized algorithm. More generally, let t be a fixed nonnegative integer and let H be a fixed graph. Let fH(G,t) be the largest integer k such that there are two k-vertex subgraphs of G having at most t vertices in common, that induce the same number of copies of H. We prove that if H has r vertices then fH(G,t)=Ω(n 1-(2r-1)/(2r+2t+1)). In particular, there are two subgraphs of the same order Ω(n1/2+1/(8r-2)) that induce the same number of copies of H and that have no copy of H in common.