/* -*- C++ -*- * * This file is a part of LEMON, a generic C++ optimization library * * Copyright (C) 2003-2006 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * * Permission to use, modify and distribute this software is granted * provided that this copyright notice appears in all copies. For * precise terms see the accompanying LICENSE file. * * This software is provided "AS IS" with no warranty of any kind, * express or implied, and with no claim as to its suitability for any * purpose. * */ #include enum {INPUT, OUTPUT, MAP_NUM}; KruskalBox::KruskalBox(std::vector t):AlgoBox() { init(t); } void KruskalBox::run() { if( tabcbt.get_active_text()!="" && (edgemapcbts[INPUT])->get_active_text()!="" && (edgemapcbts[OUTPUT])->get_active_text()!="" ) { const Graph &g=mapstorage->graph; Graph::EdgeMap * inputmap= ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]); Graph::EdgeMap outputmap(g); double res=kruskal(g, *inputmap, outputmap); for (EdgeIt i(g); i!=INVALID; ++i) { if(outputmap[i]) { (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])-> get_active_text()]))[i]=1; } else { (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])-> get_active_text()]))[i]=0; } } std::ostringstream o; o << "Result: " << res; resultlabel.set_text(o.str()); mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text()); // mapstorage->changeActiveMap(true, E_COLOR, // (edgemapcbts[OUTPUT])->get_active_text()); // mapstorage->changeActiveMap(true, E_TEXT, // (edgemapcbts[INPUT])->get_active_text()); } } void KruskalBox::build_box() { std::vector empty_vector; addMapSelector("Edgecosts: ", true); addMapSelector("Edges of tree here: ", true); resultlabel.set_text("Result: algorithm is not run yet."); pack_start(resultlabel); }