locked
Changing GViewer's Graph still keeps the old nodes and edges of the graph RRS feed

  • Question

  • Hi,

    I use the GViewer to show a specific graph. If I afterwards create a new Drawing.Graph with different nodes and edges and set GViewer to show this new graph it does not remove the previous graph, but only adds new nodes and edges to the existing graph. I tried setting GViewer.Graph to null, but it does not help.

    How can I therefore set a new graph and remove the old one? I hope I don't have to create a new instance of GViewer for that.

    Thank you for the answer.

    Gregor 

    Friday, April 2, 2010 7:58 AM

Answers

  • I found the code, it was a different problem I was recalling - I was probably altering the graph and then trying .Invalidate, instead of making a new graph object.
    Friday, April 2, 2010 7:38 PM

All replies

  • I think I had this problem, and I had to set the graph to null and then assign it to the new graph.
    Friday, April 2, 2010 3:36 PM
  • Gregor,

    Your question is not clear to me, sorry. Could you clarify it please? What are the previous graph and the existing graph? What types are they? It is true that GViewer does not remove any graphs; it relies on the garbage collector to remove the objects. From the other side I don't think GViewer reuses graphs.

    Thanks,

    Lev


    Lev Nachmanson
    Friday, April 2, 2010 5:06 PM
  • Hi Lev,

    I'm really sorry for this post.

    I found a bug in my code which caused this strange behavior. I create the graph based on the data from some dictionary. When I was updating the data in the dictionary I forgot to clear the dictionary first. Therefore it seemed as if the old graph was not removed where in fact the new graph just showed the old and new data from the dictionary. My bad. Again, sorry for my mistake...

    Thank you,

    Gregor

    Friday, April 2, 2010 6:58 PM
  • I found the code, it was a different problem I was recalling - I was probably altering the graph and then trying .Invalidate, instead of making a new graph object.
    Friday, April 2, 2010 7:38 PM