hegyi@106: #include hegyi@106: hegyi@109: enum {INPUT, OUTPUT, MAP_NUM}; hegyi@109: hegyi@108: KruskalBox::KruskalBox(std::vector t):AlgoBox() hegyi@106: { hegyi@108: init(t); hegyi@106: } hegyi@106: hegyi@106: void KruskalBox::run() hegyi@106: { hegyi@109: Graph g=mapstorage->graph; alpar@110: Graph::EdgeMap * inputmap= alpar@110: ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]); hegyi@109: Graph::EdgeMap outputmap(g); hegyi@109: double res=kruskal(g, *inputmap, outputmap); hegyi@109: hegyi@109: for (EdgeIt i(g); i!=INVALID; ++i) hegyi@109: { hegyi@109: if(outputmap[i]) hegyi@109: { alpar@110: (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])-> alpar@110: get_active_text()]))[i]=1; hegyi@109: } hegyi@109: else hegyi@109: { alpar@110: (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])-> alpar@110: get_active_text()]))[i]=0; hegyi@109: } hegyi@109: } hegyi@109: hegyi@109: std::ostringstream o; hegyi@109: o << "Result: " << res; hegyi@109: resultlabel.set_text(o.str()); hegyi@111: hegyi@111: mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text()); hegyi@111: // mapstorage->changeActiveMap(true, E_COLOR, hegyi@111: // (edgemapcbts[OUTPUT])->get_active_text()); hegyi@111: // mapstorage->changeActiveMap(true, E_TEXT, hegyi@111: // (edgemapcbts[INPUT])->get_active_text()); alpar@110: hegyi@106: } hegyi@106: hegyi@106: void KruskalBox::build_box() hegyi@106: { hegyi@109: edgemapcbts.resize(MAP_NUM); hegyi@109: Gtk::HBox * hbox; hegyi@106: hegyi@109: hbox=new Gtk::HBox(); hegyi@109: hegyi@109: label=new Gtk::Label("Edgecosts: "); hegyi@106: hegyi@106: edgemapcbts[0]=new Gtk::ComboBoxText(); hegyi@106: hegyi@106: hbox->pack_start(*label); hegyi@109: hbox->pack_start(*(edgemapcbts[INPUT])); hegyi@106: pack_start(*hbox); hegyi@109: hegyi@109: hbox=new Gtk::HBox(); hegyi@109: hegyi@109: label=new Gtk::Label("Edges of tree here: "); hegyi@109: hegyi@109: edgemapcbts[1]=new Gtk::ComboBoxText(); hegyi@109: hegyi@109: hbox->pack_start(*label); hegyi@109: hbox->pack_start(*(edgemapcbts[OUTPUT])); hegyi@109: pack_start(*hbox); hegyi@109: hegyi@109: resultlabel.set_text("Result: algorithm is not run yet."); hegyi@109: pack_start(resultlabel); hegyi@106: }