gui/kruskalbox.cc
changeset 1879 01d41844ef46
parent 1878 409a31271efd
child 1880 0d6da6e6a775
equal deleted inserted replaced
1:3d1639d3876f 2:9036363b21e8
     1 #include <kruskalbox.h>
     1 #include <kruskalbox.h>
       
     2 
       
     3 enum {INPUT, OUTPUT, MAP_NUM};
     2 
     4 
     3 KruskalBox::KruskalBox(std::vector<std::string> t):AlgoBox()
     5 KruskalBox::KruskalBox(std::vector<std::string> t):AlgoBox()
     4 {
     6 {
     5   init(t);
     7   init(t);
     6 }
     8 }
     7     
     9     
     8 void KruskalBox::run()
    10 void KruskalBox::run()
     9 {
    11 {
    10   
    12   Graph g=mapstorage->graph;
    11   std::cout << "Kruskal inditasa, de meg nincsen keszen." << std::endl;
    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);
       
    16 
       
    17   for (EdgeIt i(g); i!=INVALID; ++i)
       
    18   {
       
    19     if(outputmap[i])
       
    20       {
       
    21 	(*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()]))[i]=1;
       
    22       }
       
    23     else
       
    24       {
       
    25 	(*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()]))[i]=0;
       
    26       }
       
    27   }
       
    28 
       
    29   std::ostringstream o;
       
    30   o << "Result: " << res;
       
    31   resultlabel.set_text(o.str());
       
    32 
       
    33   mapstorage->changeActiveMap(true, E_COLOR, (edgemapcbts[OUTPUT])->get_active_text());
       
    34   mapstorage->changeActiveMap(true, E_TEXT, (edgemapcbts[INPUT])->get_active_text());
    12 }
    35 }
    13     
    36     
    14 void KruskalBox::build_box()
    37 void KruskalBox::build_box()
    15 {
    38 {
    16   edgemapcbts.resize(1);
    39   edgemapcbts.resize(MAP_NUM);
    17   Gtk::HBox * hbox=new Gtk::HBox();
    40   Gtk::HBox * hbox;
    18 
    41 
    19   std::ostringstream o;
    42   hbox=new Gtk::HBox();
    20   o << "Edgecosts: ";
    43 
    21   label=new Gtk::Label(o.str());
    44   label=new Gtk::Label("Edgecosts: ");
    22 
    45 
    23   edgemapcbts[0]=new Gtk::ComboBoxText();
    46   edgemapcbts[0]=new Gtk::ComboBoxText();
    24 
    47 
    25   hbox->pack_start(*label);
    48   hbox->pack_start(*label);
    26   hbox->pack_start(*(edgemapcbts[0]));
    49   hbox->pack_start(*(edgemapcbts[INPUT]));
    27   pack_start(*hbox);
    50   pack_start(*hbox);
       
    51 
       
    52   hbox=new Gtk::HBox();
       
    53 
       
    54   label=new Gtk::Label("Edges of tree here: ");
       
    55 
       
    56   edgemapcbts[1]=new Gtk::ComboBoxText();
       
    57 
       
    58   hbox->pack_start(*label);
       
    59   hbox->pack_start(*(edgemapcbts[OUTPUT]));
       
    60   pack_start(*hbox);
       
    61 
       
    62   resultlabel.set_text("Result: algorithm is not run yet.");
       
    63   pack_start(resultlabel);
    28 }
    64 }