I want to get all paths in a relation but I do not know how to do this if I am not given an ending Node. I have tried multiple ways to implement this and here is what I currently have...
- Rel - relation,
- S - source node (first),
- T - target node (last),
- [S|Cons] - Path,
- N - length
graph(Rel, S, T, [S|Cons], N) :- call(Rel, S, X), (X = T; graph(Rel, X, T, [X|Cons], N)).
When I test it with...
graph(myRelation, _, _, _, _), false.
It just infinitely loops. I am assuming it is because I am not given any variables of terms besides the relation but I thought when I use call it will assign X so I can populate the paths ([S|Cons]) this way.
T
andN
doing here? – Willem Van Onsem