COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/kruskalbox.cc @ 1882:2c3f6c7e01b4

Last change on this file since 1882:2c3f6c7e01b4 was 1881:f40cdc2057c2, checked in by Hegyi Péter, 18 years ago

Result of KruskalGUIAlgo is refreshed if displayed, but no more setin a forced way.

File size: 1.6 KB
RevLine 
[1876]1#include <kruskalbox.h>
2
[1879]3enum {INPUT, OUTPUT, MAP_NUM};
4
[1878]5KruskalBox::KruskalBox(std::vector<std::string> t):AlgoBox()
[1876]6{
[1878]7  init(t);
[1876]8}
9   
10void KruskalBox::run()
11{
[1879]12  Graph g=mapstorage->graph;
[1880]13  Graph::EdgeMap<double> * inputmap=
14    ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]);
[1879]15  Graph::EdgeMap<bool> outputmap(g);
16  double res=kruskal(g, *inputmap, outputmap);
17
18  for (EdgeIt i(g); i!=INVALID; ++i)
19  {
20    if(outputmap[i])
21      {
[1880]22        (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
23                                         get_active_text()]))[i]=1;
[1879]24      }
25    else
26      {
[1880]27        (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
28                                         get_active_text()]))[i]=0;
[1879]29      }
30  }
31
32  std::ostringstream o;
33  o << "Result: " << res;
34  resultlabel.set_text(o.str());
[1881]35
36  mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
37  //   mapstorage->changeActiveMap(true, E_COLOR,
38  //                          (edgemapcbts[OUTPUT])->get_active_text());
39  //   mapstorage->changeActiveMap(true, E_TEXT,
40  //                          (edgemapcbts[INPUT])->get_active_text());
[1880]41 
[1876]42}
43   
44void KruskalBox::build_box()
45{
[1879]46  edgemapcbts.resize(MAP_NUM);
47  Gtk::HBox * hbox;
[1876]48
[1879]49  hbox=new Gtk::HBox();
50
51  label=new Gtk::Label("Edgecosts: ");
[1876]52
53  edgemapcbts[0]=new Gtk::ComboBoxText();
54
55  hbox->pack_start(*label);
[1879]56  hbox->pack_start(*(edgemapcbts[INPUT]));
[1876]57  pack_start(*hbox);
[1879]58
59  hbox=new Gtk::HBox();
60
61  label=new Gtk::Label("Edges of tree here: ");
62
63  edgemapcbts[1]=new Gtk::ComboBoxText();
64
65  hbox->pack_start(*label);
66  hbox->pack_start(*(edgemapcbts[OUTPUT]));
67  pack_start(*hbox);
68
69  resultlabel.set_text("Result: algorithm is not run yet.");
70  pack_start(resultlabel);
[1876]71}
Note: See TracBrowser for help on using the repository browser.