Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Base case when MaxDist is 0 and the current article is related to AI
- collabDistWithAI(Author, Author, 0, at_least_one) :-
- articleAuthor(Article, Author),
- articleTopic(Article, artificial_intelligence).
- % Base case for when last chance to find article related to AI
- collabDistWithAI(Author1, Author2, 1, at_least_one) :-
- articleAuthor(Article, Author1),
- articleAuthor(Article, Author2),
- articleTopic(Article, artificial_intelligence).
- % Recursive call when the current article is not related to AI, continue search for AI article
- collabDistWithAI(Author1, Author2, MaxDist, at_least_one) :-
- MaxDist > 0,
- Author1 \= Author2,
- articleAuthor(Article1, Author1),
- articleAuthor(Article2, Author2),
- not articleTopic(Article, artificial_intelligence),
- NewMaxDist is MaxDist - 1,
- collabDistWithAI(Author1, Author2, NewMaxDist, at_least_one).
- % Recursive call when the current article is AI-related, no longer need to search for AI article
- collabDistWithAI(Author1, Author2, MaxDist, at_least_one) :-
- MaxDist > 0,
- Author1 \= Author2,
- articleAuthor(Article1, Author1),
- articleAuthor(Article2, Author2),
- articleTopic(Article1, artificial_intelligence),
- NewMaxDist is MaxDist - 1,
- collabDist(Author1, Author2, NewMaxDist).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement