TGraphStruct Help

Hi,

I am trying to write a script that has a continuously updating graph structure. The problem that I seem to have is that the updating part does not work for me. After I run the following code only the first two nodes and the edge between them is displayed in the canvas. The third node and the second edge never show up. If anyone has any ideas please let me know.

{
TGraphNode *n0 = new TGraphNode("n0","n0");
TGraphNode *n1 = new TGraphNode("n1","n1");
TGraphEdge *e0 = new TGraphEdge(n0,n1);
TGraphStruct *gs = new TGraphStruct();
gs->AddNode(n0);
gs->AddNode(n1);
gs->AddEdge(e0);
TCanvas *c = new TCanvas("c","c",800,600);
gs->Draw();
TGraphNode *n2 = new TGraphNode("n2","n2");
TGraphEdge *e1 = new TGraphEdge(n1,n2);
gs->AddNode(n2);
gs->AddEdge(e1);
c->Modified();
c->Update();
}

Thank you very much for your help!

TGraphStruct was not meant to be use that way.
Right now you should declare the whole graph and draw it.
I guess some developments would be required to have it working this way.

I see what you mean. I was thinking that maybe I can pull out the GetListOfNodes and GetListOfEdges and creating a new graph every time it is updated and deleting the old one. Not sure if that will work.

Radu

For example

    {
    TList *listofNodes = new TList();
    TList *listofEdges = new TList();
    TGraphNode *n0 = new TGraphNode("n0","n0");
    TGraphNode *n1 = new TGraphNode("n1","n1");
    TGraphEdge *e0 = new TGraphEdge(n0,n1);
	listofNodes->Add(n0);
	listofNodes->Add(n1);
	listofEdges->Add(e0);

    TGraphStruct *gs = new TGraphStruct();
for (int i = 0; i < listofNodes->GetSize(); i++)
gs->AddNode((TGraphNode *)listofNodes->At(i));
for (int i = 0; i < listofEdges->GetSize(); i++)
gs->AddEdge((TGraphEdge *)listofEdges->At(i));
    TCanvas *c = new TCanvas("c","c",800,600);
    gs->Draw();

    TGraphNode *n2 = new TGraphNode("n2","n2");
    TGraphEdge *e1 = new TGraphEdge(n1,n2);
	listofNodes->Add(n2);
	listofEdges->Add(e1);
delete gs;
    TGraphStruct *gs = new TGraphStruct();
for (int i = 0; i < listofNodes->GetSize(); i++)
gs->AddNode((TGraphNode *)listofNodes->At(i));
for (int i = 0; i < listofEdges->GetSize(); i++)
gs->AddEdge((TGraphEdge *)listofEdges->At(i));
gs->Draw();
    }

works as I would like to work. I bet it adds alot of computing time but for my needs the graph structure will not be very large anyways.

Radu