#include "semcheck.h" void Cd_graph::TopSort() { Adjacency_Nlist * newadjs = new Adjacency_Nlist(); adjacencies->TopSort(adjacencies,newadjs); adjacencies = newadjs; } void Adjacency_Nlist::TopSort(Adjacency_Nlist *oldadjs,Adjacency_Nlist *newadjs) { static int round = 1; Adjacency_list_iterator next(*this); Adjacency_ each; while (each = next()) { //cout << "\nRound " << round++ << endl; each->TopSort(oldadjs,newadjs); } } void Adjacency::TopSort(Adjacency_Nlist *oldadjs,Adjacency_Nlist *newadjs) { static DemNumber * mark = new DemNumber(0); //cout << "\nConsider "; //this->pp(); //cout << endl; if (this->get_dfs()) return; ns->TopSort(oldadjs,newadjs); newadjs->disjointAppend(this); this->set_dfs(mark); } void Adjacency_Nlist::disjointAppend(Adjacency_ adj) { Adjacency_list_iterator next(*this); Adjacency_ each; while (each = next()) if (each->get_source()->g_equal(adj->get_source())) return; this->append(adj); } void Neighbors::TopSort(Adjacency_Nlist *oldadjs,Adjacency_Nlist *newadjs) { } void Neighbors_wc::TopSort(Adjacency_Nlist *oldadjs,Adjacency_Nlist *newadjs) { } void Construct_ns::TopSort(Adjacency_Nlist *oldadjs,Adjacency_Nlist *newadjs) { Any_vertex_list_iterator next(*this->get_construct_ns()); Any_vertex_ each; while (each = next()) each->TopSort(oldadjs,newadjs); } void Any_vertex::TopSort(Adjacency_Nlist *oldadjs,Adjacency_Nlist *newadjs) { } void Opt_labeled_term::TopSort(Adjacency_Nlist *oldadjs,Adjacency_Nlist *newadjs) { } void Regular::TopSort(Adjacency_Nlist *oldadjs,Adjacency_Nlist *newadjs) { oldadjs->TopSort(this->get_vertex()->get_vertex(),oldadjs,newadjs); } void Adjacency_Nlist::TopSort(Vertex*avertex,Adjacency_Nlist *oldadjs,Adjacency_Nlist *newadjs) { Adjacency_list_iterator next(*this); Adjacency_ each; while (each = next()) if (each->get_source()->g_equal(avertex)) each->TopSort(oldadjs,newadjs); }