#include #include using namespace std; // Pseudokod for composition: // // Relation compose(Relation other) // { // Relation result; // for (relation in this) // { // for (relation in other) // { // if (end of relation in this == start of relation in other) // { // result.add(start of relation in this, end of relation in other); // } // } // } // return result; // } int main() { Relation r1{}; r1.add_relation(pair {'a', 'b'}); r1.add_relation(pair {'b', 'a'}); cout << "r1: " << r1.to_string() << endl; Relation r2{}; r2.add_relation(pair {'a', 'b'}); r2.add_relation(pair {'b', 'c'}); r2.add_relation(pair {'c', 'd'}); r2.add_relation(pair {'d', 'a'}); cout << "r2: " << r2.to_string() << endl; Relation r3{r1.compose(r2)}; cout << "r3: " << r3.to_string() << endl; }