7 init(t); |
7 init(t); |
8 } |
8 } |
9 |
9 |
10 void KruskalBox::run() |
10 void KruskalBox::run() |
11 { |
11 { |
12 Graph g=mapstorage->graph; |
12 if( |
13 Graph::EdgeMap<double> * inputmap= |
13 tabcbt.get_active_text()!="" && |
14 ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]); |
14 (edgemapcbts[INPUT])->get_active_text()!="" && |
15 Graph::EdgeMap<bool> outputmap(g); |
15 (edgemapcbts[OUTPUT])->get_active_text()!="" |
16 double res=kruskal(g, *inputmap, outputmap); |
16 ) |
|
17 { |
17 |
18 |
18 for (EdgeIt i(g); i!=INVALID; ++i) |
19 Graph g=mapstorage->graph; |
19 { |
20 Graph::EdgeMap<double> * inputmap= |
20 if(outputmap[i]) |
21 ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]); |
21 { |
22 Graph::EdgeMap<bool> outputmap(g); |
22 (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])-> |
23 double res=kruskal(g, *inputmap, outputmap); |
23 get_active_text()]))[i]=1; |
|
24 } |
|
25 else |
|
26 { |
|
27 (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])-> |
|
28 get_active_text()]))[i]=0; |
|
29 } |
|
30 } |
|
31 |
24 |
32 std::ostringstream o; |
25 for (EdgeIt i(g); i!=INVALID; ++i) |
33 o << "Result: " << res; |
26 { |
34 resultlabel.set_text(o.str()); |
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 } |
35 |
38 |
36 mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text()); |
39 std::ostringstream o; |
37 // mapstorage->changeActiveMap(true, E_COLOR, |
40 o << "Result: " << res; |
38 // (edgemapcbts[OUTPUT])->get_active_text()); |
41 resultlabel.set_text(o.str()); |
39 // mapstorage->changeActiveMap(true, E_TEXT, |
42 |
40 // (edgemapcbts[INPUT])->get_active_text()); |
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()); |
41 |
48 |
|
49 } |
42 } |
50 } |
43 |
51 |
44 void KruskalBox::build_box() |
52 void KruskalBox::build_box() |
45 { |
53 { |
|
54 std::vector<std::string> empty_vector; |
|
55 |
46 edgemapcbts.resize(MAP_NUM); |
56 edgemapcbts.resize(MAP_NUM); |
47 Gtk::HBox * hbox; |
|
48 |
57 |
49 hbox=new Gtk::HBox(); |
58 edgemapcbts[0]=new MapSelector(empty_vector,"","Edgecosts: ",true, false); |
|
59 edgemapcbts[0]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); |
50 |
60 |
51 label=new Gtk::Label("Edgecosts: "); |
61 pack_start(*(edgemapcbts[INPUT])); |
52 |
62 |
53 edgemapcbts[0]=new Gtk::ComboBoxText(); |
63 edgemapcbts[1]=new MapSelector(empty_vector,"","Edges of tree here: ",true, false); |
|
64 edgemapcbts[1]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); |
54 |
65 |
55 hbox->pack_start(*label); |
66 pack_start(*(edgemapcbts[OUTPUT])); |
56 hbox->pack_start(*(edgemapcbts[INPUT])); |
|
57 pack_start(*hbox); |
|
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 |
67 |
69 resultlabel.set_text("Result: algorithm is not run yet."); |
68 resultlabel.set_text("Result: algorithm is not run yet."); |
70 pack_start(resultlabel); |
69 pack_start(resultlabel); |
71 } |
70 } |