#include "Command.h" BreakCyclesCommand::BreakCyclesCommand (const CostModel& m, const Graph& graph) : Command("BreakCyclesCommand"), model(m), cycles(graph) { for( list< list >::const_iterator ptr = cycles.getAdjList().begin(); ptr != cycles.getAdjList().end(); ++ptr ) { list::const_iterator thisClass = ptr->begin(); string name = thisClass->getName(); edgesRemoved.insert( Node(name,"header",1,0) ); }// for }// constructor void BreakCyclesCommand::printComponents(const list& graphList) const { int count = 0; cout << endl; for ( list::const_iterator ptr = graphList.begin(); ptr != graphList.end(); ++ptr ) { Graph graph = (*ptr); cout << ++count << ". THE NEW CLUSTER: " << endl; graph.printWeights(cout); cout << endl; } } void BreakCyclesCommand::execute() { cout << "The number of nodes is: " << cycles.numberOfNodes() << endl; cycles.setAllWeights(model); cycles.printWeights(cout); cycles.mergeEdges(); cycles.printWeights(cout); graphList.push_back(cycles); while ( graphList.size() > 0 ) { cycles = (*graphList.begin()); graphList.pop_front(); Edge remEdge = cycles.removeLightestEdge(); edgesRemoved.addEdge(remEdge); BuildStrongComponents cmd(cycles); cmd.execute(); ++breakCount; list components = cmd.getCycles(); cout << "SIZE OF COMPONENTS: " << components.size() << endl; printComponents(components); for (list::iterator ptr = components.begin(); ptr != components.end(); ++ptr ) { if ( ptr->numberOfNodes() > 1 ) { graphList.push_back( *ptr ); } } } }