Skip to content
Snippets Groups Projects
aggregate.cpp 1.22 KiB
#include "aggregate.hpp"

#include <map>
#include <set>
#include <vector>

void Aggregate::InitWeightColumns(const std::set<int>& output_trans) {
  for (int t : output_trans) {
    columns.push_back(t);
  }
}

void Aggregate::AddWeightRow(const int in, const std::vector<int>& weight_row) {
  rows.push_back(in);
  weight.push_back(weight_row);
}

int Aggregate::PosTransOutWeight(const int t) const {
  for (int i = 0; i < columns.size(); i++) {
    if (columns[i] == t) {
      return i;
    }
  }
  return -1;
}

int Aggregate::PosTransInWeight(const int t) const {
  for (int i = 0; i < rows.size(); i++) {
    if (rows[i] == t) {
      return i;
    }
  }
  return -1;
}

int Aggregate::WeightInOut(const int in, const int out) const {
  return weight[PosTransInWeight(in)][PosTransOutWeight(out)];
}

Aggregate* Aggregate::GetsuccessorsOfTrans(int t) const
{
    for (const Edge p : successors) {
        if (p.transition == t) {
            //std::cout<<"successor by "<<t<<" found"<<std::endl;
            return p.state;
        }
    }
    return nullptr;
}
Aggregate* Aggregate::GetPredecessorsOfTrans(const int t) const {
  for (const Edge p : predecessors) {
    if (p.transition == t) {
       return p.state;
    }
  }
  return nullptr;
}