summaryrefslogtreecommitdiffstats
path: root/src/act4e_solutions/relations.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/act4e_solutions/relations.py')
-rw-r--r--src/act4e_solutions/relations.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/act4e_solutions/relations.py b/src/act4e_solutions/relations.py
index c538d4d..4fba1f1 100644
--- a/src/act4e_solutions/relations.py
+++ b/src/act4e_solutions/relations.py
@@ -60,10 +60,20 @@ class SolFiniteRelationProperties(I.FiniteRelationProperties):
class SolFiniteRelationOperations(I.FiniteRelationOperations):
def transpose(self, fr: I.FiniteRelation[A, B]) -> I.FiniteRelation[B, A]:
- raise NotImplementedError()
+ # reverses the arrows in the relation
+ values = []
+ for a in fr.source().elements():
+ for b in fr.target().elements():
+ if fr.holds(a, b):
+ values.append([b, a])
+ return MyFiniteRelation(fr.target(), fr.source(), values)
def as_relation(self, f: I.FiniteMap[A, B]) -> I.FiniteRelation[A, B]:
- raise NotImplementedError()
+ values = []
+ for a in f.source().elements():
+ values.append([a, f(a)])
+
+ return MyFiniteRelation(f.source(), f.target(), values)
class SolFiniteEndorelationProperties(I.FiniteEndorelationProperties):