COIN-OR::LEMON - Graph Library

source: glemon-0.x/kruskalbox.cc @ 145:5baba2a107a1

Last change on this file since 145:5baba2a107a1 was 145:5baba2a107a1, checked in by Alpar Juttner, 18 years ago

Bugfix (graphs are not copy constructible)

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{
[114]12  if(
13     tabcbt.get_active_text()!="" &&
14     (edgemapcbts[INPUT])->get_active_text()!="" &&
15     (edgemapcbts[OUTPUT])->get_active_text()!=""
16     )
17    {
[109]18
[145]19      const Graph &g=mapstorage->graph;
[114]20      Graph::EdgeMap<double> * inputmap=
21        ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]);
22      Graph::EdgeMap<bool> outputmap(g);
23      double res=kruskal(g, *inputmap, outputmap);
[109]24
[114]25      for (EdgeIt i(g); i!=INVALID; ++i)
26        {
27          if(outputmap[i])
28            {
29              (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
30                                               get_active_text()]))[i]=1;
31            }
32          else
33            {
34              (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
35                                               get_active_text()]))[i]=0;
36            }
37        }
[111]38
[114]39      std::ostringstream o;
40      o << "Result: " << res;
41      resultlabel.set_text(o.str());
42
43      mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
44      //   mapstorage->changeActiveMap(true, E_COLOR,
45      //                              (edgemapcbts[OUTPUT])->get_active_text());
46      //   mapstorage->changeActiveMap(true, E_TEXT,
47      //                              (edgemapcbts[INPUT])->get_active_text());
[110]48 
[114]49    }
[106]50}
51   
52void KruskalBox::build_box()
53{
[114]54  std::vector<std::string> empty_vector;
55
[116]56  addMapSelector("Edgecosts: ", true);
57  addMapSelector("Edges of tree here: ", true);
[109]58
59  resultlabel.set_text("Result: algorithm is not run yet.");
60  pack_start(resultlabel);
[106]61}
Note: See TracBrowser for help on using the repository browser.