Jump to content


Photo

how can i make it work ?


  • Please log in to reply
9 replies to this topic

#1 live_ex3me

live_ex3me
  • Members
  • PipPip
  • Member
  • 15 posts
  • LocationRomania

Posted 05 September 2006 - 02:42 PM

hi there ! this is my firs post & i ask admins to move it if it's place isn't here (but please let me know).

let's say we have this table in our database:






peoplehis_friend_id
13
21
12
32


this means:
row1: people1 has people3 as his friend
row2: people2 has people1 as his friend
row3: people1 has people2 as his friend
row4: people3 has people2 as his friend

=> 1 is frend with 3 and 2
=> 2 is frend only with 1
=> 3 is frend only with 2

now.. the question is: how can i calculate the shortest road (if it exists) between 2 people ?


There is no place like 127.0.0.1 !

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 05 September 2006 - 04:30 PM

Could you explain what you mean by "shortest road" please?

#3 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 September 2006 - 04:41 PM

Well, there's a flaw in your logic, for starters.  If 1 is friends with 3, 3 also has to be friends with 1.

To find the "shortest road", you're going to have to build relationship rules and priority.  Like, if you're trying to find out who is friends with your friends... you're going to have to do a recursive link and it's not always going to be accurate.  It will have to be smart enough to know which path to go down first and which will find the next person faster.  It'll have to be a binary tree or something similar that can traverse the entire system very quickly.

I think you'd be better off in a math/discrete math forum for something like this than asking a bunch of code monkeys.

Info: PHP Manual


#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 05 September 2006 - 05:28 PM

http://en.wikipedia....s_of_separation

Read about the mathematics of what you're asking and ignore the movie review.

In the 1950s, Ithiel de Sola Pool (MIT) and Manfred Kochen (IBM) set out to prove the theory mathematically. Although they were able to phrase the question (given a set N of people, what is the probability that each member of N is connected to another member via k1, k2, k3...kn links?), after twenty years they were still unable to solve the problem to their own satisfaction.


Have fun!!
Legend has it that reading the manual never killed anyone.
My site

#5 live_ex3me

live_ex3me
  • Members
  • PipPip
  • Member
  • 15 posts
  • LocationRomania

Posted 06 September 2006 - 09:18 AM

well .. thx but i figured it out. i have to import the database into a simetric matrix. then i'll use dijkstra's algorithm.

:-*
There is no place like 127.0.0.1 !

#6 live_ex3me

live_ex3me
  • Members
  • PipPip
  • Member
  • 15 posts
  • LocationRomania

Posted 06 September 2006 - 09:22 AM

Could you explain what you mean by "shortest road" please?

i'm trying to make something like this: www.linkedin.com . there u can ask to see if two people are "connected". how do u think it was done?
There is no place like 127.0.0.1 !

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 06 September 2006 - 10:59 AM

I went to the link as you said and looked at the website and had a play, the way the website desiner has acheved this function is using a search function.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 06 September 2006 - 12:17 PM

I went to the link as you said and looked at the website and had a play, the way the website desiner has acheved this function is using a search function.

Thanks for that contribution redarrow...

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 06 September 2006 - 01:09 PM

i am looking this up i think its a mysql function wthin mysql database seach function.

example

$query = "select * form members_info where name like '%$name% and age='31' and hair='blond' ";


know what i can see from my example is that all users with age 31 and hair blond should show i think not sure theo.

and therefore classed as a match example a matching dating mod to show who matches within the database
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 live_ex3me

live_ex3me
  • Members
  • PipPip
  • Member
  • 15 posts
  • LocationRomania

Posted 06 September 2006 - 05:49 PM

i am looking this up i think its a mysql function wthin mysql database seach function.

example

$query = "select * form members_info where name like '%$name% and age='31' and hair='blond' ";


know what i can see from my example is that all users with age 31 and hair blond should show i think not sure theo.

and therefore classed as a match example a matching dating mod to show who matches within the database


what is the beauty of www.linkedin.com: u can make friends (much like the well knowen www.hi5.com). by adding friends, u create a network. now: if u want to find a plumber for example, this is easy. the trick isn't to find a plumber, but to see if he (the plumber) is friend with one of ur own friends.

EG:

u are friend with Max, Carl and John.

John is friend with u, Max and Nick.

Nick is friend with John, Mihail and Sebastian.

Sebastian  is friend with Maria, Nick and The Plumber.

and that's the beauty of it: to be able to see "the path" between u and the man u want to hire if the path exists. in our case: u, john, nick, sebastian.

this is the part i'm not so sure how to set it done :) and it couldn't be done with a search function like "$query = "select * form members_info where name like '%$name% and age='31' and hair='blond' ";"
There is no place like 127.0.0.1 !




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users