Try to play with:
{
// create a test graph
TGraph *g = new TGraph(100);
for (Int_t i = 0; i < g->GetN(); i++) g->SetPoint(i, 0.1 * i, TMath::Sin(0.1 * i));
// in ROOT 6, you can easily make a TF1 from the TGraph::Eval function
// g->Sort(); // sort points along x axis (points must be in increasing order)
TF1 *f = new TF1("f",
[&](double*x, double *p){ return (((x[0] >= g->GetX()[0]) && (x[0] <= g->GetX()[(g->GetN() - 1)])) ? g->Eval(x[0]) : 0.0); },
g->GetX()[0], g->GetX()[(g->GetN() - 1)], 0);
f->SetNpx(3 * g->GetN());
g->Draw("A*");
std::cout << "pseudo-integral = " << g->Integral() << std::endl;
f->Draw("SAME");
std::cout << "integral = " << f->Integral(f->GetXmin(), f->GetXmax()) << std::endl;
}
BTW. Depending on the “shapes” of your graphs, you may face problems with ROOT’s “integrators”: