tleisher Posted September 7, 2006 Share Posted September 7, 2006 Is there a way to take data and make a graphical social network from a website database? I run a community that has a friends list on our message board, and I want to make a graphical representation of each persons friends through a social network.. like this:http://upload.wikimedia.org/wikipedia/en/a/ae/Social-network.pngHow would I do this? Quote Link to comment Share on other sites More sharing options...
Barand Posted September 7, 2006 Share Posted September 7, 2006 Depends on whether the data you have is suitable for producing such a network. Quote Link to comment Share on other sites More sharing options...
Caesar Posted September 7, 2006 Share Posted September 7, 2006 If your database was well designed and the data is infact suitable, I would recommend looking into using Ajax for this. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 7, 2006 Share Posted September 7, 2006 [quote author=Caesar link=topic=107282.msg430198#msg430198 date=1157669069]If your database was well designed and the data is infact suitable, I would recommend looking into using Ajax for this.[/quote]Why AJAX specifically? Quote Link to comment Share on other sites More sharing options...
tleisher Posted September 7, 2006 Author Share Posted September 7, 2006 How would my database need to be layed out and how would I go about doing it? Quote Link to comment Share on other sites More sharing options...
Barand Posted September 7, 2006 Share Posted September 7, 2006 Perhaps a [b]person [/b]table and a [b]friends[/b] table to define who is friends with whom[pre]person table friend table---------------------- -------------------------person_id | name | |person_id | friend_id |----------|----------| |----------|-------------| 1 | Peter | | 1 | 2 | 2 | Paul | | 1 | 3 | 3 | Mary | | 2 | 1 | | 2 | 3 | | 3 | 1 | | 3 | 2 |[/pre]which would give[pre] 1 / \ 2 - 3[/pre] Quote Link to comment Share on other sites More sharing options...
tleisher Posted September 7, 2006 Author Share Posted September 7, 2006 But then how would I get it into a graphical representation? Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 8, 2006 Share Posted September 8, 2006 How? With a great deal of mathematics, logic, and an understanding of the GD library. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 8, 2006 Share Posted September 8, 2006 You need to allocate positions on the image for the personsBy querying the table you know which persons connect to which, so draw line from person to friend using the coordinates from the placement of the persons on the grid. If you only select those records where person_id less than friend_id you can avoid duplication here.The really tricky bit is positioning on the grid.If you decide on[pre] 1 2 3 [/pre] then when you join them you get [pre] 1 -- 2 -- 3 [/pre] but that hides the 1 -- 3 relationship Similarly, you have to avoid putting all in a different row and column which could give [pre] 1 \ 2 \ 3[/pre]So you have to come up with a positioning algorithm that gives[pre] 1 - 2 or 1 \ | | \ 3 2--3[/pre]It's possible but not a trivial task. Good luck Quote Link to comment 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.