0

Let's say we have to two people, one from London and one from Istanbul. And both of them do not share any mutual friends. But we know that they are both related with several friends' of friends'. I want to find that connection. (I store the friendships on database). Is there any name for this algorithm?

So the output will be something like: Egbert<->John<->Ivan<->Samuil<->Cengiz

ilhan
  • 8,700
  • 35
  • 117
  • 201
  • 1
    This seems to be a repeat of six degrees of separation http://stackoverflow.com/questions/2076715/challenge-how-to-implement-an-algorithm-for-six-degree-of-separation – johnsoe Jan 04 '14 at 00:09

1 Answers1

0

It seems the classic problem to find the route between two points in a node graph for which usually is used the A* (A star) algorithm.

Here you can find more information about it and a php implementation of it.

http://en.wikipedia.org/wiki/A*_search_algorithm

http://althenia.net/svn/stackoverflow/a-star.php?rev=7

tudo75
  • 97
  • 1
  • 2