# 获取CPU温度 from time import sleep from pyspectator.processor import Cpu cpu = Cpu(monitoring_latency=1) with cpu: whileTrue: print(f’Temp: {cpu.temperature} °C’) sleep(2)
Label Propagation Algorithm,也称作标签传播算法(LPA),是一个在图中快速发现社群的算法,由Raghavan等人在2007年于论文《Near linear time algorithm to detect community structures in large-scale networks》中提出。在 LPA 算法中,节点的标签完全由它的直接邻居决定。标签传播算法是一种基于标签传播的局部社区发现算法,其基本思想是节点的标签(community)依赖其邻居节点的标签信息,影响程度由节点相似度决定,并通过传播迭代更新达到稳定。
library(igraph)library(d3Network)igraphDat <- read.graph(file = "/Users/wuzhengxiang/Documents/PPT模板/0.edges", directed = FALSE) ## Simplify to remove duplications and from-self-to-self loopsigraphDat <- simplify(igraphDat, remove.multiple = TRUE, remove.loops = TRUE ) ## Give numbersV(igraphDat)$label <- seq_along(V(igraphDat)) ## Average path length between any two given nodes(averagePathLength <- average.path.length(igraphDat)) ## Community structure detection based on edge betweennesscommunityEdgeBetwn <- edge.betweenness.community(igraphDat) ## Check the transitivity of a graph (probability that the adjacent vertices of a vertex are connected)(transitivityDat <- transitivity(igraphDat, type = "localaverage", isolates = "zero") ) ## Set the seed to get the same resultset.seed("20200513") ## Add community indicating background colorsplot(igraphDat,vertex.color = communityEdgeBetwn$membership, vertex.size = log(degree(igraphDat) + 1),mark.groups = by(seq_along(communityEdgeBetwn$membership), communityEdgeBetwn$membership, invisible) ) ## Annotatetitle("Stanford Facebook data", sub = "http://snap.stanford.edu/data/egonets-Facebook.html" )text(x = -1, y = -1, labels = sprintf("Average path length: %.2fnTransitivity: %.2f", averagePathLength, transitivityDat) )