科学网

 找回密码
  注册

tag 标签: modularity

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

Python+NetworkX 计算全局社区划分的模块度的三种方法,代码分享
datamining1 2016-1-13 20:55
#Python代码 #coding=gbk import numpy as np import networkx as nx ''' 输入参数格式说明 comm= , ,...] G=nx.Graph() Q1、Q2、Q3是采用三种不同方法来计算模块度,其结果相同 G中边(a,b)都是ab, 如果查询(b,a) 是不是图的边,返回的结果为false(得到的返回结果是错的,这是个坑,要注意) ''' def Q1(comm,G): #边的个数 edges=G.edges() m=len(edges) #print 'm',m #每个节点的度 du=G.degree() #print 'du',du #通过节点对(同一个社区内的节点对)计算 ret=0.0 for c in comm: for x in c: for y in c: #边都是前小后大的 #不能交换x,y,因为都是循环变量 if x=y: if (x,y) in edges: aij=1.0 else: aij=0.0 else: if (y,x) in edges: aij=1.0 else: aij=0 #print x,' ',y,' ',aij tmp=aij-du *du *1.0/(2*m) #print du ,' ',du #print tmp ret=ret+tmp #print ret #print ' ' ret=ret*1.0/(2*m) #print 'ret ',ret return ret def Q2(comm,G): #边的个数 edges=G.edges() m=len(edges) #print 'm',m #每个节点的度 du=G.degree() #print 'du',du #通过节点对计算 ret2=0.0 for c in comm: #首先计算出社区c中的边的个数 #这样计算出来的边数是实际边数的2倍 bian=0 for x in c: for y in c: #边都是前小后大的 #不能交换x,y,因为都是循环变量 if x=y: if (x,y) in edges: bian=bian+1 else: if (y,x) in edges: bian=bian+1 #社区c内的节点度的和 duHe=0 for x in c: duHe=duHe+du tmp=bian*1.0/(2*m)-(duHe*1.0/(2*m))*(duHe*1.0/(2*m)) #print 'bian',bian,'tmp',tmp ret2=ret2+tmp return ret2 def Q3(comm,G): #社区个数 k=len(comm) #边数 m=G.number_of_edges() print 'm',m #边列表 edges=G.edges() #k*k的矩阵e e=np.zeros((k,k),np.float) for i in range(k): for j in range(k): #计算comm 和comm 之间的边数 #由于是对称矩阵,只需要计算上三角即可 bian=0 for x in comm : for y in comm : if xy: if (x,y) in edges: bian=bian+1 else: if (y,x) in edges: bian=bian+1 #如果i==j,边重复了一遍,需要除以2 if i==j: bian=bian/2 #如果i==j,e 是边数/m if i==j: e =bian*1.0/m else:#如果i!=j,e 是边数/m的一半 e =bian*0.5/m #e =bian #endforj #endfori print e #1*k的行向量a a=np.zeros(k,np.float) for i in range(k): he=0 for j in range(k): he=he+e a =he # print a QValue=0 for i in range(k): QValue=QValue+e -a *a # return QValue
个人分类: 复杂网络|18683 次阅读|0 个评论
我的新书 "Modularity"
热度 2 jiankuihe 2011-3-11 15:31
我的新书 "Modularity"
应Lambert Academic Publishing之邀,我写的书 Modularity: The Principle of Evolution in Complex Systems今天出版了。 此书总结了我数年来在复杂网络,金融物理,和免疫系统进化方面的工作。主题围绕着“模块化” (modularity)展开。此书的核心是提出了生物进化中的模块化定律。 Modularity, understanding systems as the combination of separated components, is a prevalent concept in biology, social science and engineering design. This book offers a general theoretical model of emergence of modularity during evolution in changing environments. Evidences from protein interaction network and protein domain network support this theory as a general law of evolution in complex systems. Applying it to animal development, this theory appears to provide an explanation for the occurrence and timing of the Cambrian explosion. Applying it to trade networks, this theory predicts that globalized economy is more sensitive to recessions. This book also introduces a quantitative measure of hierarchy, a statistical method to predict the dominant flu strain and the first theoretical model to explain the bacterial acquired immunity (CRISPR). The information in the book should help shed some light in the study of complex systems, flu vaccine, and bacterial antibiotic resistance. 购买链接: http://www.amazon.com/Modularity-principle-evolution-complex-systems/dp/3844311416 前后封面
6749 次阅读|2 个评论
模块化的字节码验证
tangtang1987 2010-7-1 14:19
For all the literatures I have seen, modular reasoning for object-oriented programs is only concerned on the source code level. I'm wondering is this because we don't need modularity at low-level code, or compared to other verification challenges of bytecode, modular reasoning is, to some extent, too far away from applications? Most modular reasoning methodologies are based on Liskov's behavioral subtyping( or its extensions), while sometimes it is too concrete for OO programs. What I wanna to do is using Parkinson's APF to verify source program(java, for example), and then translated into bytecode proof. On the level of method call, proof obligation of APF is preserved by non-optimized complilers. But I still need to prove that, and think more about the significance of modular reasoning on bytecode.
个人分类: 字节码语言|2802 次阅读|0 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-16 11:31

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部