From: SourceForge.net <no...@so...> - 2010-09-19 10:57:31
|
The following forum message was posted by eltonhcchan at http://sourceforge.net/projects/jung/forums/forum/252062/topic/3857536: Hi there, I create a MST based on MinimumSpanningTreeDemo.java. After MST is created and display on a JFrame, I remove one vertex from the graph model, e.g. graph.removeVertex("8"); I check that the graph is updated that vertex "8" and related edges are removed. However, the MST didn't update accordingly. Anybody help point out how to update the MST and also the display? Following is portion of the code for easy reference. MinimumSpanningForest<Number,String> prim = new MinimumSpanningForest<Number,String>(g, new DelegateForest<Number,String>(),null); tree = prim.getForest(); // 1 tree only System.out.println("1 " +tree.getVertexCount()); //return 20 vertices //The Layout<V, E> is parameterized by the vertex and edge types Layout<Number,String> layout = new TreeLayout<Number,String>(tree); Dimension preferredSizeRect = new Dimension(500,250); final VisualizationModel<Number,String> vm1 = new DefaultVisualizationModel<Number,String>(layout, preferredSizeRect); final VisualizationViewer<Number,String> vv = new VisualizationViewer<Number,String>(vm1,preferredSizeRect); // detect model change and repaint viewer vm1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("ChangeEvent hitted."); vv.repaint(); // expect vertex 8 and related edges removed but nothing happened. } }); System.out.println("2 " +tree.getVertexCount()); //return 20 vertices again thanks |