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