Clustering Coefficient

article/2025/10/29 15:40:07

Define

Clustering Coefficient:聚类系数

Clustering Coefficient measures the degree to which nodes in a network tend to cluster or form triangles.

——聚类系数衡量网络中节点倾向于聚类或形成三角形的程度

Triadic Closure

三元闭包

The tendency of people who share connections in a social network to become connected

“Triadic Closure would say that those edges that closed triangles are good candidate for edges that may show up next”

那些能形成闭合三角形的边,往往被认为是下一个会出现的边

但我们并不会总是有时间戳,也并不是总是知道边缘进入网路的顺序

Another way of referring to Triadic Closure is Clustering.

——另一种指代三元闭包的方式是聚类

Local Clustering Coefficient

局部聚类系数

We’re going to be measuring Clustering from the point of view of a single node.

——从单个顶点的角度测量聚类

  • define:

Fraction of pairs of the node’s friends that are friends with each other.
# o f p a i r s o f C ′ s f r i e n d s w h o a r e f r i e n d s # o f p a i r s o f C ′ f r i e n d s \frac{\#\,\,\,of\,\,\,pairs\,\,\,of\,\,\,C's\,friends\,\,\,who \,\,\,are\,\,\,friends}{\#\,\,\,of \,\,\,pairs\,\,\,of\,\,\,C'\,friends} #ofpairsofCfriends#ofpairsofCsfriendswhoarefriends
在这里插入图片描述

i n s t a n c e # o f C ′ f r i e n d s = d c = 4 ( t h e d e g r e e o f C ) # o f p a i r s o f C ′ f r i e n d s = d c ( d c − 1 ) 2 = 12 2 = 6 # o f p a i r s o f C ′ s f r i e n d s w h o a r e f r i e n d s = 2 L o c a l c l u s t e r i n g c o e f f i c e n t o f C = 2 6 = 1 3 instance\\ \#\,\,\,of\,\,\,C'\,friends=d_c=4(the\,\,\,degree\,\,\,of\,\,\,C)\\ \#\,\,\,of \,\,\,pairs\,\,\,of\,\,\,C'\,friends=\frac{d_c(d_c-1)}{2}=\frac{12}{2}=6\\ \#\,\,\,of\,\,\,pairs\,\,\,of\,\,\,C's\,friends\,\,\,who \,\,\,are\,\,\,friends=2\\ Local\,\,\,clustering\,\,\,coefficent\,\,\,of\,\,\,C=\frac{2}{6}=\frac{1}{3} instance#ofCfriends=dc=4(thedegreeofC)#ofpairsofCfriends=2dc(dc1)=212=6#ofpairsofCsfriendswhoarefriends=2LocalclusteringcoefficentofC=62=31

解释

  1. C结点一共有4个结点
  2. 4个结点能形成6对朋友
  3. 但真正存在的朋友是AB和EF两对

When we look at the node J,we will find we have a trouble because we cannot divide by zero.
# o f J ′ f r i e n d s = d c = 1 ( t h e d e g r e e o f J ) # o f p a i r s o f J ′ f r i e n d s = 0 \#\,\,\,of\,\,\,J'\,friends=d_c=1(the\,\,\,degree\,\,\,of\,\,\,J)\\ \#\,\,\,of \,\,\,pairs\,\,\,of\,\,\,J'\,friends=0 #ofJfriends=dc=1(thedegreeofJ)#ofpairsofJfriends=0
In this situation,we will assume that the local clustering coefficient of a node of degree less than 2 to be 0.

我们将入度少于2的点,认为其局部聚类系数为0

import networkx as nxG=nx.Graph()
G.add_edges_from([('A','K'),('A','B'),('A','C'),('B','C'),('B','K'),('C','E'),
('C','F'),('D','E'),('E','F'),('E','H'),('F','G'),('I','J')])print(nx.clustering(G,'F'))
#>>0.3333333333333333print(nx.clustering(G,'J'))
#>>0

Global Clustering Coefficient

全局聚类系数

Approach One

Average local clustering coefficient over all nodes in the graph

——图中所有结点的平均局部聚类系数

print(nx.average_clustering(G))
#>>0.28787878787878785

Approach Two

Measuring clustering on the whole network

Percentage of “open triads” that are triangles in a network

  • Triangles are simply three nodes that are connected by three edges.
  • open triads are three nodes that are connected by only two edges.

T r a n s i t i v i t y = 3 ∗ N u m b e r o f c l o s e d t r i a d s N u m b e r o f o p e n t r i a d s Transitivity=\frac{3*Number\,\,\,of\,\,\,closed\,\,\,triads}{Number\,\,\,of\,\,\,open\,\,\,triads} Transitivity=Numberofopentriads3Numberofclosedtriads
Transitivity:Ratio of number of triangles and number of “open triads” in a network

——网络中三角形数量与“开放三元组”数量之比

print(nx.transitivity(G))
#>>0.4090909090909091

Approach Diff

  • Both try to measure the tendency for the edges to form triangles

  • Transitivity weights the nodes with a larger degree higher.

    ——Transitivity 对具有高入度的结点给予更高的权重

E x a m p l e − 1 Example-1 Example1

在这里插入图片描述

  1. Most nodes have a pretty high LCC(Local Clustering Coefficient)

    外面那圈结点的LCC都是1

  2. The high degree node has low LCC

    中间结点是高入度的结点,LCC偏低为 1 11 \frac{1}{11} 111

O u t C o m e OutCome OutCome

  1. Ave.clustering coeff.=0.93
  2. Transitivity=0.23

E x a m p l e − 2 Example -2 Example2

在这里插入图片描述

  1. Most nodes have low LCC

    外围的结点度数为0

  2. The high degree node has low LCC

    中间部分的结点是完全图,LCC高

O u t C o m e OutCome OutCome

  1. Ave.clustering coeff.=0.25
  2. Transitivity=0.86

http://chatgpt.dhexx.cn/article/pKTG9KxY.shtml

相关文章

covariate(covariate是控制变量吗)

如何用STATA对连续性变量进行meta回归分析 在stata中有个metareg命令,好像可以对连续变量进行回归分析。 附件中是一篇pdf文档,主要介绍stata中关于meta分析的命令。跟大家分享一下。 里面在提到metareg命令时,列举了以下三个列子&#xff1a…

协方差矩阵简介(Covariance Matrix)

协方差矩阵定义 首先我们要明白,协方差实际是在概率论和统计学中用于衡量两个变量的总体误差,当然方差是协方差的一种特殊情况,即当两个变量是相同情况。它表示的是两个变量的总体的误差,这与只表示一个变量误差的方差不同。如果两个变量的变…

covariance matrix

协方差的定义 对于一般的分布,直接代入E(X)之类的就可以计算出来了,但真给你一个具体数值的分布,要计算协方差矩阵,根据这个公式来计算,还真不容易反应过来。这里用一个例子说明协方差矩阵是怎么计算出来的吧。 记住&…

经典排序算法——堆排序

对于一个int数组,请编写一个堆排序算法,对数组元素排序。 给定一个int数组A及数组的大小n,请返回排序后的数组。 测试样例: [1,2,3,5,2,3],6 [1,2,2,3,3,5] class HeapSort { public:int* heapSort(int* A, int n) {BuildMaxHeap(…

堆排序算法原理及c++实现

文章目录 准备知识MAX-HEAPIFY过程建堆堆排序算法总结 准备知识 堆的结构可以分为最大堆和最小堆,是一个完全二叉树,而堆排序是根据堆的这种数据结构设计的一种排序。 所谓完全二叉树即叶节点只能出现在最下层和次下层,并且最下面一层的结点…

堆排序算法设计与分析

堆排序(HeapSort)是指利用堆积树(堆)这种数据结构所设计的一种排序算法,它是选择排序的一种。堆分为大根堆和小根堆,是完全二叉树。大根堆要求父结点的值大于或等于子结点的值,小根堆相反。根据大根堆的性质,我们可以知道最大值一…

堆排序算法实现

堆排序:结构逻辑上是完全二叉树,但是可以使用顺序存储来实现 一些二叉树的区别: 二叉树:度数最大为2并且每个子树也是二叉树 满二叉树:每层节点都是满的,没有空缺,也就是,叶子节点只能出现在最后一层 完全二叉树:限制条件比满二叉树弱化,只需要前k-1层是满二叉树结构,最后…

数据结构之堆排序算法详解+C语言实现

堆   堆是具有以下性质的完全二叉树:每个结点的值都大于或等于其左右孩子结点的值,称为大顶堆;或者每个结点的值都小于或等于其左右孩子结点的值,称为小顶堆。 堆排序   堆排序是利用堆这种数据结构而设计的一种排序算法&…

堆排序算法原理及实现

堆排序是排序中一种比较重要的算法,和快速排序一样,其复杂度也是O(nlogn);同时也是一种原地排序算法:在任何时候,数组中只有常数个元素存储在输入数组以外。堆这种数据结构是处理海量数据比较常见的结构,海…

堆排序算法Java

基本原理 1):将带排序的序列构造成一个大顶堆,根据大顶堆的性质,当前堆的根节点(堆顶)就是序列中最大的元素 2):将堆顶元素和最后一个元素交换,然后将剩下的节点重新构造成一个大顶堆; 3):重复步骤2 小知识…

堆排序算法详细分析

一、堆相关概念 1.堆 堆是完全二叉树,即除最后一层外,其它层都是满的,且最后一层从左到右依次都有元素。如下图所示。 堆是用数组来实现的,图中下标就为数组的下标,其对应数组[5, 1, 7, 2, 8, 6, 3, 9, 4]&#xf…

数据结构——堆排序(算法)

基本介绍 1)、堆排序是利用堆这种数据结构而设计的一种排序算法,堆排序是一种选择排序,它的最好、最坏、平均时间复杂度均为O(nlogn),它也是不稳定排序。2)、堆是具有以下性质的完全二叉树:每个节点的值都…

C++:堆排序算法详解

图解排序算法(三)之堆排序 预备知识 堆排序 堆排序是利用堆这种数据结构而设计的一种排序算法,堆排序是一种选择排序,它的最坏,最好,平均时间复杂度均为O(nlogn),它也是不稳定排序。首先简单了解下堆结构。 堆 堆是具有…

排序算法:堆排序算法实现及分析

堆排序介绍 堆排序(Heap Sort)就来利用堆(假设利用大顶堆)进行排序的方法。它的基本思想是,将待排序的序列构成一个大顶堆。此时,整个序列的最大值就是堆顶的根结点。将它移走(其实就是将其与堆…

堆排序算法 总结

最近面试,老是被问到堆排序算法。 回答时老是感觉思路不清楚,现在总结一下,把思路弄清楚的。 1.堆排序是利用堆的特性对记录序列进行排序的一种排序方法。 好的那么堆得特性是什么呢? 堆得定义: 堆是满足下列性质的数…

Java实现堆排序算法

堆排序是计算机编程中一种流行且高效的排序算法。学习如何编写堆排序算法需要了解两种类型的数据结构-数组和树。 我们要排序的初始数字集存储在数组中,例如[10, 3, 76, 34, 23, 32],排序后,我们得到一个排序后的数组[3,10,23,32,34,76] 堆排…

精通八大排序算法系列:二、堆排序算法

精通八大排序算法系列:二、堆排序算法 作者:July 、二零一一年二月二十日本文参考:Introduction To Algorithms,second edition。------------------- 此精通排序算法系列,前一节,已讲过了一、快速排序算法&#xff0c…

堆排序算法详解

一、堆排序算法原理和动态图解 将待排序的序列构造成一个大顶堆。此时,整个序列的最大值就是堆顶的根节点。将它移走(其实就是将其与堆数组的末尾元素交换,此时末尾元素就是最大值),然后将剩余的n-1个序列重新构造成一个堆,这样就…

【堆排序算法】(C语言实现)

堆排序 一.堆排序1.堆的概念及性质1.1堆的概念1.2堆的性质 二.向下调整和向上调整两大算法1. 向下调整算法2.1 向下调整算法基本思路 2. 向上调整算法2.2 向上调整的基本思路 三.堆的实现(小堆)1.头文件包含2. 接口实现 四.任意树调整为堆(小…

堆排序算法

堆排序 堆排序(Heapsort)是指利用堆这种数据结构所设计的一种排序算法。堆积是一个近似完全二叉树的结构,并同时满足堆积的性质:即子结点的键值或索引总是小于(或者大于)它的父节点。 基本思想 利用大顶堆…