using dynamic_cast for tgraphs