Jump to content


Photo

Is there a way?


  • Please log in to reply
8 replies to this topic

#1 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 07 September 2006 - 10:27 PM

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.wikime...ial-network.png

How would I do this?

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 07 September 2006 - 10:41 PM

Depends on whether the data you have is suitable for producing such a network.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 07 September 2006 - 10:44 PM

If your database was well designed and the data is infact suitable, I would recommend looking into using Ajax for this.
PHP Ninja

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 07 September 2006 - 10:47 PM

If your database was well designed and the data is infact suitable, I would recommend looking into using Ajax for this.


Why AJAX specifically?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 07 September 2006 - 11:12 PM

How would my database need to be layed out and how would I go about doing it?

#6 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 07 September 2006 - 11:45 PM

Perhaps a person table and a friends 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]
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#7 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 07 September 2006 - 11:52 PM

But then how would I get it into a graphical representation?

#8 AndyB

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

Posted 08 September 2006 - 12:00 AM

How?  With a great deal of mathematics, logic, and an understanding of the GD library. 
Legend has it that reading the manual never killed anyone.
My site

#9 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 08 September 2006 - 12:16 AM

You need to allocate positions on the image for the persons

By 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
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users