Solved

database of social networking in prolog

Posted on 2008-10-27
2
329 Views
Last Modified: 2012-05-05
I am currently building a social networking stuff, similar like facebook or friendster and  I  a bit stuck in this part where I need to have a predicate that basically says " who is X friends with, through at most two intermediate people, and what is the path?" I have a database in my prolog file which is something like:

fr(chris, geen).
fr(geen,jill).
fr(jill, clark).

I want to create a prolog predicate called friend(X,Y,Z). An example I want it to do something like

friend(chris,clark,L).
L = [chris, geen, jill, clark].
....
and other stuff according what it finds in the database.

I know that I am suppose to use recursion here and backtracking, as well as the cut operation to tell the function to stop when it finds a friend more than 2 bridges. Can someone please help me one this
0
Comment
Question by:kuntilanak
2 Comments
 
LVL 45

Accepted Solution

by:
Kdo earned 500 total points
Comment Utility
In database terms, you'll want to join two friends together, then join all of the friends of one of them.

Friend A has 10 friends, one of which is B.
Freind B has 15 friends, two of which are A and C.  It doesn't matter if C is a friend of A.

Join all of the friends of A and B.  To this list join all of the friends of C.  Friend A is now joined to the friends of C.


Kent
0
 

Author Comment

by:kuntilanak
Comment Utility
can you help me to code that a bit in prolog.. cause that's where my confusion is
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This video teaches viewers about errors in exception handling.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now