如何创建社交图谱?
这对我来说是一个完全陌生的领域。谁能指出我如何创建社交图以及表示它的最佳方式的正确方向?我正在用 C#/asp net 构建一个网站,需要创建一个“朋友”功能...这种类型的东西通常完全存储在数据库中吗?如果是这样,怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您最关心的是绘制社交网络的图片还是存储数据?
对于存储,您可以考虑 图形数据库。然而,这个领域最成熟的产品是 Neo4j,顾名思义,它是用 Java 编写的。这个SO讨论列表一些针对.Net的替代方法。
编辑
您仍然不清楚是否需要设计建议或代码示例。 Andrew Siemer 撰写了一篇由两部分组成的文章,其中概述了 问题,然后介绍一些 ASP.net 代码。我认为这无论如何都不是一个完整的解决方案,但它可以为您指明正确的方向。
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.
你的问题是相当开放式的。对于绘制复杂的图形,我最喜欢的工具之一是 Graphviz。 Graphviz 可以处理有向图或无向图。它可以将输入作为简单的文本文件,然后以各种格式输出图形。
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.
因此,您的问题主要是数据存储问题,以及如何存储和检索图中的边。将一些简单的图形术语应用于您的问题:
节点/顶点:在您的情况下,每个人将代表一个节点。
边/链接:节点之间的关系(在本例中为“朋友”)将在两个节点之间创建无向边。
边/链接:
因此,您需要在数据库中维护一个数据结构,以允许您解决朋友之间的边缘关系。
一些有用的信息可能可以在此问题中找到:
挑战-如何实现六度分离的算法
此外,在决定如何存储边缘列表时,您应该考虑的是您认为您的网站将有多少个边缘产生。这可能会影响您决定的存储机制。
希望这些指点有所帮助。
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.