live_ex3me Posted September 5, 2006 Share Posted September 5, 2006 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 2now.. the question is: how can i calculate the shortest road (if it exists) between 2 people ? Quote Link to comment https://forums.phpfreaks.com/topic/19773-how-can-i-make-it-work/ Share on other sites More sharing options...
zq29 Posted September 5, 2006 Share Posted September 5, 2006 Could you explain what you mean by "shortest road" please? Quote Link to comment https://forums.phpfreaks.com/topic/19773-how-can-i-make-it-work/#findComment-86498 Share on other sites More sharing options...
ober Posted September 5, 2006 Share Posted September 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/19773-how-can-i-make-it-work/#findComment-86502 Share on other sites More sharing options...
AndyB Posted September 5, 2006 Share Posted September 5, 2006 http://en.wikipedia.org/wiki/Six_degrees_of_separationRead 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!! Quote Link to comment https://forums.phpfreaks.com/topic/19773-how-can-i-make-it-work/#findComment-86527 Share on other sites More sharing options...
live_ex3me Posted September 6, 2006 Author Share Posted September 6, 2006 well .. thx but i figured it out. i have to import the database into a simetric matrix. then i'll use dijkstra's algorithm. :-* Quote Link to comment https://forums.phpfreaks.com/topic/19773-how-can-i-make-it-work/#findComment-86963 Share on other sites More sharing options...
live_ex3me Posted September 6, 2006 Author Share Posted September 6, 2006 [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? Quote Link to comment https://forums.phpfreaks.com/topic/19773-how-can-i-make-it-work/#findComment-86965 Share on other sites More sharing options...
redarrow Posted September 6, 2006 Share Posted September 6, 2006 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 Link to comment https://forums.phpfreaks.com/topic/19773-how-can-i-make-it-work/#findComment-86998 Share on other sites More sharing options...
zq29 Posted September 6, 2006 Share Posted September 6, 2006 [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... Quote Link to comment https://forums.phpfreaks.com/topic/19773-how-can-i-make-it-work/#findComment-87037 Share on other sites More sharing options...
redarrow Posted September 6, 2006 Share Posted September 6, 2006 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 Link to comment https://forums.phpfreaks.com/topic/19773-how-can-i-make-it-work/#findComment-87060 Share on other sites More sharing options...
live_ex3me Posted September 6, 2006 Author Share Posted September 6, 2006 [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' ";" Quote Link to comment https://forums.phpfreaks.com/topic/19773-how-can-i-make-it-work/#findComment-87282 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.