Jump to content

how can i make it work ?


live_ex3me

Recommended Posts

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:
[table]
[tr][td]people[/td][td]his_friend_id[/td][/tr]
[tr][td]1[/td][td]3[/td][/tr]
[tr][td]2[/td][td]1[/td][/tr]
[tr][td]1[/td][td]2[/td][/tr]
[tr][td]3[/td][td]2[/td][/tr]
[/table]

this means:
[b]row1:[/b] [i]people1[/i] has [i]people3[/i] as his friend
[b]row2:[/b] [i]people2[/i] has [i]people1[/i] as his friend
[b]row3:[/b] [i]people1[/i] has [i]people2[/i] as his friend
[b]row4:[/b] [i]people3[/i] has [i]people2[/i] 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 ?

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

http://en.wikipedia.org/wiki/Six_degrees_of_separation

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

[quote]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.[/quote]

Have fun!!
Link to comment
Share on other sites

[quote author=SemiApocalyptic link=topic=106956.msg428552#msg428552 date=1157473806]
Could you explain what you mean by "shortest road" please?
[/quote]
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?
Link to comment
Share on other sites

[quote author=redarrow link=topic=106956.msg429089#msg429089 date=1157540375]
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.
[/quote]Thanks for that contribution redarrow...
Link to comment
Share on other sites

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
Link to comment
Share on other sites

[quote author=redarrow link=topic=106956.msg429160#msg429160 date=1157548194]
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
[/quote]

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.

[b]EG:[/b]

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 [u][b]The Plumber[/b][/u].

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' ";"
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.