Jump to content

Archived

This topic is now archived and is closed to further replies.

tleisher

Is there a way?

Recommended Posts

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.png

How would I do this?

Share this post


Link to post
Share on other sites
Depends on whether the data you have is suitable for producing such a network.

Share this post


Link to post
Share on other sites
If your database was well designed and the data is infact suitable, I would recommend looking into using Ajax for this.

Share this post


Link to post
Share on other sites
[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?

Share this post


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

Share this post


Link to post
Share on other sites
How?  With a great deal of mathematics, logic, and an understanding of the GD library. 

Share this post


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

Share this post


Link to post
Share on other sites

×

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.