1

I’m creating a facebook application which matches people people based on a set of criteria, and I figure it’s pretty easy to make a query to search the database for people matching the criteria EXACTLY, but was wondering how websites normally generate results which don’t exactly match the criteria.

I was thinking of something like a tally system where I look at the first parameter and find all the people who match that and increment a counter for their id, then look at the second and increment a counter for all the ones which match that etc. Then just display the results for the cases with the highest counters. The problem with this is that some criteria may be more important than others and I guess this could be solved with giving them a higher weighting i.e. increment counter by higher value.

So my questions are:

  1. How do websites normally do this and are there any standard php recipes for this?
  2. Is the algorithm I suggested feasible?
  3. What is this general area called? (I don't know what I should be searching google for...)
user1058210
  • 1,639
  • 7
  • 29
  • 49
  • Try [fuzzy logic](http://en.wikipedia.org/wiki/Fuzzy_logic). – ghoti Jul 25 '12 at 10:51
  • Take a look at [n-dimensional matching algorithm](http://stackoverflow.com/questions/677987/n-dimensional-matching-algorithm?rq=1) and [Divide and Conquer](http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm) which is a very powerful algorithm for matching objects based on criterias – Romain Jul 25 '12 at 10:54

1 Answers1

1

I think the search term is in your question :-) I would recommend this approach:

Treat this as a graph where each of 'N' people are connected to everyone else.
Assign weights to the edges depending on whatever your application is.

Then try to find the maximum matching in a bipartite graph.
This is a well known problem. Try searching for Network flow+ bipartite graphs.

Arvind
  • 466
  • 3
  • 9