社区(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,后处理被用于输出社区。

 1 public int speakerVote() {
 2         //Run through each element in the map to create a cumulative distribution
 3         Set<Integer> communityIds = communityDistribution.keySet();
 4         ArrayList<Integer> communities = new ArrayList<Integer>();
 5         ArrayList<Integer> cumulativeCounts = new ArrayList<Integer>();
 6
 7         int sum=-1;
 8         for (Integer comm: communityIds) {
 9             sum += communityDistribution.get(comm);
10             communities.add(comm);
11             cumulativeCounts.add(sum);
12         }
13
14         //Generate a random integer in the range [0,sum)
15         int rand = RandomNumGenerator.getRandomInt(sum+1);
16
17         //Find the index of first value greater than rand in cumulativeCounts
18         int i=0;
19         for (i=0; i<cumulativeCounts.size(); i++) {
20             if (cumulativeCounts.get(i)>=rand)
21                 break;
22         }
23
24         //Return the corresponding community
25         return communities.get(i);
26     }

SpeakerVote

 1 public void updateLabels(Integer userId){
 2         Set<DefaultWeightedEdge> incomingEdges = userNodegraph.getGraph().incomingEdgesOf(userId);//获取所有该顶点的入度顶点
 3         Map<Integer, Integer> incomingVotes = new HashMap<Integer, Integer>();//所有speaker顶点投票情况
 4
 5         //For each vertex V with an incoming edge to the current node
 6         for ( DefaultWeightedEdge edge: incomingEdges ) {
 7             int speakerId = userNodegraph.getGraph().getEdgeSource(edge);
 8             UserNode speakerNode = userNodegraph.getNodeMap().get(speakerId);
 9
10             int votedCommunity = speakerNode.speakerVote();
11             int votedCommunitycount = 1;
12             if ( incomingVotes.containsKey(votedCommunity)){
13                 votedCommunitycount += incomingVotes.get(votedCommunity);
14             }
15             incomingVotes.put(votedCommunity, votedCommunitycount);
16         }
17
18         //Find the most popular vote
19         Iterator<Entry<Integer, Integer>> it = incomingVotes.entrySet().iterator();
20         int popularCommunity=-1;
21         int popularCommunityCount=0;
22         while ( it.hasNext()) {
23             Entry<Integer, Integer> entry = it.next();
24             if ( entry.getValue() > popularCommunityCount ) {
25                 popularCommunity = entry.getKey();
26                 popularCommunityCount = entry.getValue();
27             }
28         }
29         //Update community distribution of the current node by 1
30         UserNode currentNode = userNodegraph.getNodeMap().get(userId);
31         currentNode.updateCommunityDistribution(popularCommunity, 1);
32     }

listenerUpdateCommunity

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

转载于:https://www.cnblogs.com/limin12891/p/5660350.html

社区发现SLPA算法相关推荐

  1. 社区发现算法python视频_社区发现FN算法Python实现

    社区发现FN算法Python实现 算法原理 评价指标 结果对比 源码 ​2004年,Newman在GN(Girvan and Newman, 2002)算法的基础上,提出了另外一种快速检测社区的算法, ...

  2. 社会网络中基于标签传播的社区发现新算法

    社会网络中基于标签传播的社区发现新算法 文章发表时间 :2012年3月 1. 本文贡献 提出了基于标签影响值的社区发现发算法,在接近线性的时间复杂度下,选取一个小的顶点集合作为种子集进行传播 综合考虑 ...

  3. 社区发现FN算法Python实现

    社区发现FN算法Python实现 算法原理 评价指标 结果对比 源码 一种高效实现 ​2004年,Newman在GN(Girvan and Newman, 2002)算法的基础上,提出了另外一种快速检 ...

  4. 重叠社区发现-LFM算法

    #coding=utf-8 from numpy import * #文件读取 def LoadAdjacentMatrixData(filename,vertices):Adjmartrix = [ ...

  5. 社区发现 SSN-LDA算法 学习笔记

    SSN-LDA(Simple Social Network-LDA)是一种基于潜在狄利克雷分配的分层贝叶斯算法,在SSN-LDA中,社区被建模为图形模型中的潜在变量,并被定义为社会参与者空间上的分布. ...

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

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

  7. 【机器学习】聚类算法、社区发现

    目录 前言 聚类和社区发现 社区发现 聚类算法 聚类-评估指标 社区发现-模块度 前言 最近方向是团案挖掘,关于聚类算法和社区发现,其实之前不怎么了解,最近得补补了. 聚类和社区发现 首先要先明白这两 ...

  8. fastunfolding算法_社区发现算法综述—part1

    目前我能在arxiv上找到的最新的关于社区发现算法系列的综述文了. 正文从这里开始: 2.2 社区发现 现代网络在规模.多样性和复杂性上呈指数增长. 由于网络的变化,各种各样呈现出网络结构的不同类型的 ...

  9. 社区发现(一)--算法综述

    基础概念简介:https://baike.baidu.com/item/%E7%A4%BE%E5%8C%BA%E5%8F%91%E7%8E%B0%E7%AE%97%E6%B3%95/19460396 ...

最新文章

  1. 【高并发】Redis如何助力高并发秒杀系统?看完这篇我彻底懂了!!
  2. js闭包循环原因_常见的三个 JS 面试题
  3. logistic回归--好文
  4. 【CodeForces - 920E】Connected Components? (dsu,补图连通块,STLset+map,bfs 或bitset)
  5. Linux驱动(13)--传递参数
  6. 黄聪:主机宝安装wordpress注意事项
  7. 批处理打开和关闭oracle11g 服务
  8. shell学习之跳出循环
  9. series 锐捷rgrsr20_锐捷RG-RSR20-04E路由器
  10. 驱动开发:BSOD 0x7E(8000003)或命中断点卡住,__security_init_cookie导致
  11. 编写java格式_编写Java程序打印个人信息,个人信息格式如下:
  12. 【JS】每日一题:模块化
  13. ZT I Believe I Can Fly(我相信我能飞)
  14. 手把手教你画圆锥渐变
  15. 干货总结!太全面了,图解SQL面试题:经典30题!
  16. 计算机安全模式win7,Win7如何进入计算机安全模式?
  17. CentOS下修改IRedMail的邮件附件大小
  18. 自我解读MVC三层架构原理
  19. xcode不支持ios12beta系统
  20. 菲尔兹奖得主小平邦彦:数学是什么?

热门文章

  1. mysql格式分隔符row_MySQLRow格式Binlog的解析(1)
  2. 1-5docker私有镜像仓库
  3. BZOJ 1086 [SCOI2005]王室联邦(树分块)
  4. 20179214 《网络攻防实践》第五周学习
  5. Ubuntu 8.04下Netbeans的字体反锯齿解决(转)
  6. java8 入门脚本之家_Java 8中的Lambda表达式
  7. mybatis 一对一 一对多 级联查询
  8. Promise解决多个异步Ajax请求导致的代码嵌套问题(完美解决方案)
  9. Android 截图,截取指定view截图
  10. zsh: command not found: service