diff -r 409a31271efd -r 01d41844ef46 gui/kruskalbox.cc --- a/gui/kruskalbox.cc Thu Jan 05 12:30:09 2006 +0000 +++ b/gui/kruskalbox.cc Thu Jan 05 16:54:34 2006 +0000 @@ -1,5 +1,7 @@ #include +enum {INPUT, OUTPUT, MAP_NUM}; + KruskalBox::KruskalBox(std::vector t):AlgoBox() { init(t); @@ -7,22 +9,56 @@ void KruskalBox::run() { - - std::cout << "Kruskal inditasa, de meg nincsen keszen." << std::endl; + Graph g=mapstorage->graph; + Graph::EdgeMap * inputmap=((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]); + Graph::EdgeMap outputmap(g); + double res=kruskal(g, *inputmap, outputmap); + + for (EdgeIt i(g); i!=INVALID; ++i) + { + if(outputmap[i]) + { + (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()]))[i]=1; + } + else + { + (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()]))[i]=0; + } + } + + std::ostringstream o; + o << "Result: " << res; + resultlabel.set_text(o.str()); + + mapstorage->changeActiveMap(true, E_COLOR, (edgemapcbts[OUTPUT])->get_active_text()); + mapstorage->changeActiveMap(true, E_TEXT, (edgemapcbts[INPUT])->get_active_text()); } void KruskalBox::build_box() { - edgemapcbts.resize(1); - Gtk::HBox * hbox=new Gtk::HBox(); + edgemapcbts.resize(MAP_NUM); + Gtk::HBox * hbox; - std::ostringstream o; - o << "Edgecosts: "; - label=new Gtk::Label(o.str()); + hbox=new Gtk::HBox(); + + label=new Gtk::Label("Edgecosts: "); edgemapcbts[0]=new Gtk::ComboBoxText(); hbox->pack_start(*label); - hbox->pack_start(*(edgemapcbts[0])); + hbox->pack_start(*(edgemapcbts[INPUT])); pack_start(*hbox); + + hbox=new Gtk::HBox(); + + label=new Gtk::Label("Edges of tree here: "); + + edgemapcbts[1]=new Gtk::ComboBoxText(); + + hbox->pack_start(*label); + hbox->pack_start(*(edgemapcbts[OUTPUT])); + pack_start(*hbox); + + resultlabel.set_text("Result: algorithm is not run yet."); + pack_start(resultlabel); }