Retrieving an unnamed TGraph

{
  // https://root.cern.ch/root/html534/TFile.html
  TFile *f = TFile::Open("MyFile.root");
  // https://root.cern.ch/root/html534/TDirectoryFile.html
  gDirectory->ls();
  // https://root.cern.ch/root/html534/TList.html
  TList *l = gDirectory->GetListOfKeys();
  for (Int_t i = 0; i < l->GetSize(); i++) ((TKey *)(l->At(i)))->ls();
  TGraph *g = 0;
  for (Int_t i = 0; i < l->GetSize(); i++) {
    // https://root.cern.ch/root/html534/TKey.html
    TKey *k = ((TKey *)(l->At(i)));
    if (TString("TGraph").EqualTo(k->GetClassName())) {
      std::cout << "A TGraph was found." << std::endl;
      g = dynamic_cast<TGraph *>(k->ReadObj());
      break;
    }
  }
  if (g) g->Draw("A*");
}

BTW. If you need to retrieve, e.g., TGraphAsymmErrors objects, replace all occurrences of TGraph in this macro with TGraphAsymmErrors.