社区(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. 指针也是一种数据类型
  2. mysql表创建在哪_mysql创建表命令是哪句
  3. 【控制】如何入门自动控制理论
  4. JDBC对MySQL数据库存储过程的调用
  5. [react] 怎么使用Context开发组件?
  6. java1.8.0,jdk1.8.0版本
  7. SAP License:新总帐行项目无法显示
  8. [SCOI 2010]字符串
  9. 善待自己:改变命运的N个人生哲理
  10. 乐味煲耳机软件中文版解读
  11. 计算机信息网络安全保护管理条例,中华人民共和国计算机信息系统安全保护条例...
  12. PS抠印章|证件照换背景
  13. 《鸡啄米C++编程入门系列》系列技术文章整理收藏
  14. R语言实验报告【全集】
  15. 变分模态分解 python_浅谈VMD(变分模态分解)
  16. 2021年中式烹调师(中级)考试内容及中式烹调师(中级)实操考试视频
  17. 运维工程师 常见的 trouble shooting 故障排错思路
  18. NYOJ 82 迷宫寻宝
  19. java 计算体积_Java抽象类计算体积
  20. 手动删除7千万个Reids的Key是什么体验响!

热门文章

  1. 学完php在学python_写给PHP程序员的 Python学习指南(建议去看原文)
  2. springboot security 权限不足_springBoot整合springSecurity(零一)
  3. 00_python安装与配置(mac)
  4. 行为类模式(二):命令(Command)
  5. C#秘密武器之反射——基础篇
  6. 升级ADT22.6后,Android模拟器无法创建
  7. easyUI 添加CheckBox选择到DataGrid
  8. html title属性无效_【学习教程】使用JavaScript删除CSS属性
  9. html表格背景图片格式,HTML表格标记教程(8):背景图像属性BACKGROUND
  10. spring 多线程 事务 源码解析(一)