this is a totally unfamiliar area for me. can anyone point me in the right direction on how to create a social graph and the best way to represent it? i'm building a website in C#/asp net and need to create a "friends" feature... is this type of thing usually stored entirely in the DB? if so, how?
-
1Are you asking how you could represent relationships between friends in graph form visually on your website? Some more detailed information on your problem will produce a more accurate answer. – Binary Nerd Feb 07 '10 at 22:15
3 Answers
Is your primary concern painting a picture of the social network or storing the data?
For storage you might consider a graph database. However, the most mature product in this space is neo4j, which has the name suggests is written in Java. This SO discussion list some alternative approaches for .Net.
edit
You are still not being clear whether you need design advice or code samples. Andrew Siemer wrote a two-part article which outlines the issues and then presents some ASP.net code. I don't think it's by any means a complete solution but it could give you a steer in the right direction.
-
basically i need to do what you do on facebook. i need to be able to make friends and then be able to see your friends list, click on them to see their profiles, etc. i just don't know the best way to store this data and how to retrieve/manipulate it. – ijjo Feb 07 '10 at 22:34
-
The first question is how much traffic is expected for your site? Do you need to optimize the "friends list" for read...or write? If the write can be eventually consistent...then optimize the read site (likely the higher volume of traffic). Also, think about the data structure. You might keep a flat copy of data for a given view already stitched together for a user...denormalized data. Let me know if I can help. – Andrew Siemer Aug 15 '14 at 18:55
-
1@AndrewSiemer - your offer of help is extremely kind. However, as the question is over four years old it is also more than somewhat late. – APC Aug 16 '14 at 08:24
Your question is rather open-ended. For drawing complex graphs, one of my favorite tools is Graphviz. Graphviz can work with directed or non-directed graphs. It can take the input as a simple text file, and then output the graph in a variety of formats.

- 2,027
- 3
- 19
- 24
So your problem is primarily a data storage issue, and how to store and retrieve edges in your graph. Applying some simple graph terms to your problem:
Node/Vertex: In your case each person will represent a node.
Edge/Link: The relationship between nodes, in this case 'friends', will create an undirected edge between two nodes.
So you will need to maintain a data structure in your DB that allows you to resolve the edge relationships between friends.
Some useful information can probably be found in this question:
challenge-how-to-implement-an-algorithm-for-six-degree-of-separation
Also, something you should consider when deciding how to store your edge list is how many edges you think your site will generate. This will probably effect the storage mechanism you decide on.
Hope those pointers help.

- 1
- 1

- 13,872
- 4
- 42
- 44