COIN-OR::LEMON - Graph Library

source: glemon-0.x/kruskalbox.cc @ 110:99935b512b1c

gui
Last change on this file since 110:99935b512b1c was 110:99935b512b1c, checked in by Alpar Juttner, 14 years ago

Reformatting: too long code lines.

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