Kruskal algorithm can be run from GUI from now on.
1 #include <kruskalbox.h>
3 enum {INPUT, OUTPUT, MAP_NUM};
5 KruskalBox::KruskalBox(std::vector<std::string> t):AlgoBox()
10 void KruskalBox::run()
12 Graph g=mapstorage->graph;
13 Graph::EdgeMap<double> * inputmap=((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]);
14 Graph::EdgeMap<bool> outputmap(g);
15 double res=kruskal(g, *inputmap, outputmap);
17 for (EdgeIt i(g); i!=INVALID; ++i)
21 (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()]))[i]=1;
25 (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()]))[i]=0;
30 o << "Result: " << res;
31 resultlabel.set_text(o.str());
33 mapstorage->changeActiveMap(true, E_COLOR, (edgemapcbts[OUTPUT])->get_active_text());
34 mapstorage->changeActiveMap(true, E_TEXT, (edgemapcbts[INPUT])->get_active_text());
37 void KruskalBox::build_box()
39 edgemapcbts.resize(MAP_NUM);
44 label=new Gtk::Label("Edgecosts: ");
46 edgemapcbts[0]=new Gtk::ComboBoxText();
48 hbox->pack_start(*label);
49 hbox->pack_start(*(edgemapcbts[INPUT]));
54 label=new Gtk::Label("Edges of tree here: ");
56 edgemapcbts[1]=new Gtk::ComboBoxText();
58 hbox->pack_start(*label);
59 hbox->pack_start(*(edgemapcbts[OUTPUT]));
62 resultlabel.set_text("Result: algorithm is not run yet.");
63 pack_start(resultlabel);