社区(community)定义:同一社区内的节点与节点之间关系紧密,而社区与社区之间的关系稀疏。

设图G=G(V,E),所谓社区发现是指在图G中确定nc(>=1)个社区C={C1,C2,...,Cnv},使得各社区的顶点集合构成V的一个覆盖。

若任意两个社区的顶点集合的交际均为空,则称C为非重叠社区(disjoint communities);否则称为重叠社区(overlapping communities)。

SLPA(Speaker-listener Label Propagation Algorithm)算法是一种社区发现算法,它是对LPA算法(标签传播算法)的拓展。

算法思想如下:

输入参数:迭代次数T,满足社区次数要求的阈值r

输出参数:每一个节点的社区分布

(1)首先,每一个节点的存储器中初始化一个唯一的标签。

(2)然后,重复进行以下步骤,直到达到最大迭代T:

  a. 选择一个节点作为监听器;

  b. 所选节点的每个邻居随机选择概率正比于该标签在其存储器中的出现频率的标签,把所选择的标签(speakervote)发送到听众(listener);

  c. 监听器增加接收到的最流行的标签到内存。

(3)最后,根据在存储器里的标签和阈值r,后处理被用于输出社区。

 public int speakerVote() {
//Run through each element in the map to create a cumulative distribution
Set<Integer> communityIds = communityDistribution.keySet();
ArrayList<Integer> communities = new ArrayList<Integer>();
ArrayList<Integer> cumulativeCounts = new ArrayList<Integer>(); int sum=-1;
for (Integer comm: communityIds) {
sum += communityDistribution.get(comm);
communities.add(comm);
cumulativeCounts.add(sum);
} //Generate a random integer in the range [0,sum)
int rand = RandomNumGenerator.getRandomInt(sum+1); //Find the index of first value greater than rand in cumulativeCounts
int i=0;
for (i=0; i<cumulativeCounts.size(); i++) {
if (cumulativeCounts.get(i)>=rand)
break;
} //Return the corresponding community
return communities.get(i);
}

SpeakerVote

 public void updateLabels(Integer userId){
Set<DefaultWeightedEdge> incomingEdges = userNodegraph.getGraph().incomingEdgesOf(userId);//获取所有该顶点的入度顶点
Map<Integer, Integer> incomingVotes = new HashMap<Integer, Integer>();//所有speaker顶点投票情况 //For each vertex V with an incoming edge to the current node
for ( DefaultWeightedEdge edge: incomingEdges ) {
int speakerId = userNodegraph.getGraph().getEdgeSource(edge);
UserNode speakerNode = userNodegraph.getNodeMap().get(speakerId); int votedCommunity = speakerNode.speakerVote();
int votedCommunitycount = 1;
if ( incomingVotes.containsKey(votedCommunity)){
votedCommunitycount += incomingVotes.get(votedCommunity);
}
incomingVotes.put(votedCommunity, votedCommunitycount);
} //Find the most popular vote
Iterator<Entry<Integer, Integer>> it = incomingVotes.entrySet().iterator();
int popularCommunity=-1;
int popularCommunityCount=0;
while ( it.hasNext()) {
Entry<Integer, Integer> entry = it.next();
if ( entry.getValue() > popularCommunityCount ) {
popularCommunity = entry.getKey();
popularCommunityCount = entry.getValue();
}
}
//Update community distribution of the current node by 1
UserNode currentNode = userNodegraph.getNodeMap().get(userId);
currentNode.updateCommunityDistribution(popularCommunity, 1);
}

listenerUpdateCommunity

注:源代码请联系limin12891@163.com.

社区发现SLPA算法的更多相关文章

  1. SLAP(Speaker-Listener Label Propagation Algorithm)社区发现算法

    其中部分转载的社区发现SLPA算法文章 一.概念 社区(community)定义:同一社区内的节点与节点之间关系紧密,而社区与社区之间的关系稀疏. 设图G=G(V,E),所谓社区发现是指在图G中确定n ...

  2. 网络科学 - 社区发现 Community structure and detection及其几个实现工具

    首先什么是社区(Community structure)呢?其实并不是指一个网络相互连接的部分,而是一个网络中链接“紧密的部分”,至于怎么定义紧密就有很多方法了. 社区发现算法可以参考下面的博客:博客 ...

  3. 社区发现(Community Detection)算法 [转]

    作者: peghoty 出处: http://blog.csdn.net/peghoty/article/details/9286905 社区发现(Community Detection)算法用来发现 ...

  4. 社区发现(Community Detection)算法(转)

    作者: peghoty 出处: http://blog.csdn.net/peghoty/article/details/9286905 社区发现(Community Detection)算法用来发现 ...

  5. 社区发现(Community Detection)算法

    作者: peghoty 出处: http://blog.csdn.net/peghoty/article/details/9286905 社区发现(Community Detection)算法用来发现 ...

  6. 模块度与Louvain社区发现算法

    Louvain算法是基于模块度的社区发现算法,该算法在效率和效果上都表现较好,并且能够发现层次性的社区结构,其优化目标是最大化整个社区网络的模块度. 模块度(Modularity) 模块度是评估一个社 ...

  7. 社区发现算法问题&&NetworkX&&Gephi

    在做东西的时候用到了社区发现,因此了解了一下有关社区发现的一些问题 1,社区发现算法 (1)SCAN:一种基于密度的社团发现算法 Paper: <SCAN: A Structural Clust ...

  8. 社区发现算法 - Fast Unfolding(Louvian)算法初探

    1. 社团划分 0x1:社区是什么 在社交网络中,用户相当于每一个点,用户之间通过互相的关注关系构成了整个网络的结构. 在这样的网络中,有的用户之间的连接较为紧密,有的用户之间的连接关系较为稀疏.其中 ...

  9. Top Leaders社区发现算法(top leaders community detection approach in information networks)

    一.概念 复杂网络:现实生活中各种系统都可以看做成复杂网络,复杂网络构成包括节点和边,节点是网络中的基本组成单元,节点之间的联系或者关系是网络中的边.例如 电力网络:基站代表节点,基站之间是否互通表示 ...

随机推荐

  1. [SoapUI]怎样获取隐藏元素的文本内容Get text of hidden element

    隐藏元素无法通过gettext()获取其文本内容,须用javascript来获取 String actualDataPointName = (String) ((JavascriptExecutor) ...

  2. Smart Pointe

    http://blog.chinaunix.net/uid-625789-id-2720884.html

  3. mybatis Generator 生成配置文件

    <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE generatorConfiguration ...

  4. alertView 上添加textField

    - (void)showTextFieldUIAlertView {     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@ ...

  5. phonegap/cordova学习建议

    在技术群里面,一直有一些新人进来,问了一些让人可笑不得的问题.国内的资料相对比较少,而且很旧,都是一些2.X版本的资料.因此想写一些东西,帮助一下新人,让他们少走弯路. 首先说一些很多人问的问题,个人 ...

  6. 洛谷P3224 [HNOI2012]永无乡(线段树合并+并查集)

    题目描述 永无乡包含 nnn 座岛,编号从 111 到 nnn ,每座岛都有自己的独一无二的重要度,按照重要度可以将这 nnn 座岛排名,名次用 111 到 nnn 来表示.某些岛之间由巨大的桥连接, ...

  7. The J-Link hardware debugging Eclipse plug-in

    Quicklinks If you already know what are the features of the new plug-in and just want to know how to ...

  8. .Net Mvc5Filter与权限认证扩展

    WebForm 在做WebForm的时候,如果我们要实现某页面登陆后才能访问,这个非常容易实现 public partial class IndexForm : Page { protected vo ...

  9. MVC中获取所有按钮,并绑定事件!

    <script> var btns = $('[id=addbtn]'); //不能直接使用#ID来获取,必须用[] //循环遍历所有的按钮,一个一个添加事件绑定   for (var i ...

  10. ASP.NET基于Aspose.Words插入Word水印以及多个水印

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Da ...