kruskalbox.cc
branchgui
changeset 109 9f8dc346ac6e
parent 108 bf355fd6563e
child 110 99935b512b1c
     1.1 --- a/kruskalbox.cc	Thu Jan 05 12:30:09 2006 +0000
     1.2 +++ b/kruskalbox.cc	Thu Jan 05 16:54:34 2006 +0000
     1.3 @@ -1,5 +1,7 @@
     1.4  #include <kruskalbox.h>
     1.5  
     1.6 +enum {INPUT, OUTPUT, MAP_NUM};
     1.7 +
     1.8  KruskalBox::KruskalBox(std::vector<std::string> t):AlgoBox()
     1.9  {
    1.10    init(t);
    1.11 @@ -7,22 +9,56 @@
    1.12      
    1.13  void KruskalBox::run()
    1.14  {
    1.15 -  
    1.16 -  std::cout << "Kruskal inditasa, de meg nincsen keszen." << std::endl;
    1.17 +  Graph g=mapstorage->graph;
    1.18 +  Graph::EdgeMap<double> * inputmap=((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]);
    1.19 +  Graph::EdgeMap<bool> outputmap(g);
    1.20 +  double res=kruskal(g, *inputmap, outputmap);
    1.21 +
    1.22 +  for (EdgeIt i(g); i!=INVALID; ++i)
    1.23 +  {
    1.24 +    if(outputmap[i])
    1.25 +      {
    1.26 +	(*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()]))[i]=1;
    1.27 +      }
    1.28 +    else
    1.29 +      {
    1.30 +	(*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()]))[i]=0;
    1.31 +      }
    1.32 +  }
    1.33 +
    1.34 +  std::ostringstream o;
    1.35 +  o << "Result: " << res;
    1.36 +  resultlabel.set_text(o.str());
    1.37 +
    1.38 +  mapstorage->changeActiveMap(true, E_COLOR, (edgemapcbts[OUTPUT])->get_active_text());
    1.39 +  mapstorage->changeActiveMap(true, E_TEXT, (edgemapcbts[INPUT])->get_active_text());
    1.40  }
    1.41      
    1.42  void KruskalBox::build_box()
    1.43  {
    1.44 -  edgemapcbts.resize(1);
    1.45 -  Gtk::HBox * hbox=new Gtk::HBox();
    1.46 +  edgemapcbts.resize(MAP_NUM);
    1.47 +  Gtk::HBox * hbox;
    1.48  
    1.49 -  std::ostringstream o;
    1.50 -  o << "Edgecosts: ";
    1.51 -  label=new Gtk::Label(o.str());
    1.52 +  hbox=new Gtk::HBox();
    1.53 +
    1.54 +  label=new Gtk::Label("Edgecosts: ");
    1.55  
    1.56    edgemapcbts[0]=new Gtk::ComboBoxText();
    1.57  
    1.58    hbox->pack_start(*label);
    1.59 -  hbox->pack_start(*(edgemapcbts[0]));
    1.60 +  hbox->pack_start(*(edgemapcbts[INPUT]));
    1.61    pack_start(*hbox);
    1.62 +
    1.63 +  hbox=new Gtk::HBox();
    1.64 +
    1.65 +  label=new Gtk::Label("Edges of tree here: ");
    1.66 +
    1.67 +  edgemapcbts[1]=new Gtk::ComboBoxText();
    1.68 +
    1.69 +  hbox->pack_start(*label);
    1.70 +  hbox->pack_start(*(edgemapcbts[OUTPUT]));
    1.71 +  pack_start(*hbox);
    1.72 +
    1.73 +  resultlabel.set_text("Result: algorithm is not run yet.");
    1.74 +  pack_start(resultlabel);
    1.75  }