32 const std::vector<size_t>& permutationOfSCCs)
const {
35 int costOfPermutation = -1;
37 auto it_k = permutationOfSCCs.begin() +
sccOrder.size();
39 for (
auto it_i = permutationOfSCCs.begin(); it_i != permutationOfSCCs.end(); ++it_i, costOfSCC = 0) {
44 if (std::find(permutationOfSCCs.begin(), it_i, scc) == it_i) {
52 for (
auto it_j = permutationOfSCCs.begin(); it_j != it_i; ++it_j) {
55 if (std::find(permutationOfSCCs.begin(), it_i, scc) == it_i) {
62 if (costOfSCC > costOfPermutation) {
63 costOfPermutation = costOfSCC;
66 return costOfPermutation;
72 bool hasUnvisitedSuccessor =
false;
73 bool hasUnvisitedPredecessor =
false;
76 for (
const auto scc_i : successorsToVisit) {
80 hasUnvisitedPredecessor =
false;
82 for (
const auto scc_j : successorsPredecessors) {
83 if (!visited[scc_j]) {
84 hasUnvisitedPredecessor =
true;
88 if (!hasUnvisitedPredecessor) {
90 visited[scc_i] =
true;
104 hasUnvisitedPredecessor =
false;
106 for (
const auto scc_j : predecessors) {
107 if (!visited[scc_j]) {
108 hasUnvisitedPredecessor =
true;
112 hasUnvisitedSuccessor =
false;
114 for (
const auto scc_j : successors) {
115 if (!visited[scc_j]) {
116 hasUnvisitedSuccessor =
true;
122 if (hasUnvisitedSuccessor && !hasUnvisitedPredecessor) {
129 sccGraph = translationUnit.getAnalysis<SCCGraphAnalysis>();
132 std::vector<bool> visited;
134 std::fill(visited.begin(), visited.end(),
false);
152 os <<
"--- partial order of strata as list of pairs ---" << std::endl;
153 for (
size_t sccIndex = 0; sccIndex <
sccOrder.size(); sccIndex++) {
157 os << sccIndex <<
" " << sccIndex << std::endl;
160 for (
const auto successorScc : successorSccs) {
161 const auto successorSccIndex = *std::find(
sccOrder.begin(),
sccOrder.end(), successorScc);
162 os << sccIndex <<
" " << successorSccIndex << std::endl;
165 os <<
"--- total order with relations of each strata ---" << std::endl;
169 [](std::ostream& out,
const Relation*
rel) { out << rel->getQualifiedName(); });
170 os <<
"]" << std::endl;
173 os <<
"--- statistics of topological order ---" << std::endl;