#include "semcheck.h" //#define DEBUG void Cd_graph::SolveEQs(Cd_graph* originalCd) { #ifdef DEBUG cout << "\n=======================================\n"; //originalCd->get_adjacencies()->print_fset(cout); cout << "\n=======================================\n"; #endif #ifdef DEBUG cout << "\nBegin with originalCd->AddAltsToGraph(this);" << endl; #endif originalCd->AddAltsToGraph(this); #ifdef DEBUG cout << "\nBegin with originalCd->AddSCCWithOneToGraph(this);" << endl; #endif originalCd->AddSCCWithOneToGraph(this); #ifdef DEBUG cout << "\nBegin with this->SCCStart();" << endl; #endif this->SCCStart(); #ifdef DEBUG cout << "\nBegin with Cd_graph * SCCGraph = this->BuildSCCGraph();" << endl; #endif Cd_graph * SCCGraph = this->BuildSCCGraph(); #ifdef DEBUG cout << "\nAfter Cd_graph * SCCGraph = this->BuildSCCGraph();" << endl; //SCCGraph->CYCLE_FREE_SUBGRAPH_START(); SCCGraph->cd_pp(cout); cout << "\nBegin with SCCGraph->TopSort();" << endl; #endif SCCGraph->TopSort(); #ifdef DEBUG cout << "\n=======================================\n"; SCCGraph->cd_pp(cout); cout << "\n"; SCCGraph->get_adjacencies()->print_fset(cout); cout << "\n=======================================\n"; #endif SCCGraph->FinishupFset(originalCd); #ifdef DEBUG cout << "\n=======================================\n"; SCCGraph->cd_pp(cout); cout << "\n"; SCCGraph->get_adjacencies()->print_fset(cout); cout << "\n=======================================\n"; #endif } void Cd_graph::AddSCCWithOneToGraph(Cd_graph*fsetcd) { adjacencies->AddSCCWithOneToGraph(fsetcd); } void Adjacency_Nlist::AddSCCWithOneToGraph(Cd_graph*fsetcd) { Adjacency_list_iterator next(*this); Adjacency_ each; while (each = next()) each->AddSCCWithOneToGraph(fsetcd); } void Adjacency::AddSCCWithOneToGraph(Cd_graph*fsetcd) { fsetcd->CheckAndAdd(source); } void Cd_graph::CheckAndAdd(Vertex *V) { adjacencies->CheckAndAdd(V); } void Adjacency_Nlist::CheckAndAdd(Vertex *V) { Adjacency_list_iterator next(*this); Adjacency_ each; while (each = next()) if (each->get_source()->g_equal(V)) return; Adjacency_ new_adj = new Adjacency(); new_adj->set_source(V); Construct_ns* cons_n = new Construct_ns(); cons_n->set_construct_ns(new Any_vertex_List()); new_adj->set_ns(cons_n); this->append(new_adj); } void Cd_graph::AddAltsToGraph(Cd_graph*fsetcd) { adjacencies->AddAltsToGraph(fsetcd); } void Adjacency_Nlist::AddAltsToGraph(Cd_graph*fsetcd) { Adjacency_list_iterator next(*this); Adjacency_ each; while (each = next()) each->AddAltsToGraph(fsetcd); } void Adjacency::AddAltsToGraph(Cd_graph*fsetcd) { ns->AddAltsToGraph(fsetcd,source); } void Neighbors::AddAltsToGraph(Cd_graph*fsetcd,Vertex*borrower) { } void Neighbors_wc::AddAltsToGraph(Cd_graph*fsetcd,Vertex*borrower) { } void Alternat_ns::AddAltsToGraph(Cd_graph*fsetcd,Vertex*borrower) { Term_list_iterator next(*this->get_alternat_ns()); Term_ each; while (each = next()) fsetcd->AddOneEdge(each->get_vertex(),borrower); }