?
Solved

database of social networking in prolog

Posted on 2008-10-27
2
Medium Priority
?
339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 46

Accepted Solution

by:
Kent Olsen earned 1500 total points
ID: 22814648
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
ID: 22814681
can you help me to code that a bit in prolog.. cause that's where my confusion is
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

719 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