Jump to content

Is there a way?


tleisher

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?
Link to comment
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]
Link to comment
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
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.