gpt4 book ai didi

algorithm - 我的子例程对于生成随机 Barabasi-Albert 图是否正确?

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:17:13 26 4
gpt4 key购买 nike

<分区>

我想生成一个具有 10,000 个节点的随机 Barabasi-Albert 图,但我的程序非常慢。如果我的子程序正确与否,有人可以帮忙吗?在我的代码中,ran1() 是标准的随机数生成器。感谢您的帮助。

 ***********************************************************************
subroutine barabasi_albert(kon,n,m0,m,a,idum)
***********************************************************************
implicit real*8(a-h,o-z)
implicit integer*4(i-n)
logical linked(n) ! logical array for storing if a node is connected
! to the current one
dimension kon(n,n) ! connectivity matrix
! m0: number of initial nodes
! m: minimal degree
! a: scale parameter
! idum: argument to the random number generation
c
c Initialize kon(:,:)
c
kon(:n,:n)=0
c
c Create complete graph of m0 node
c
kon(:m0,:m0)=1
do i=1,m0
kon(i,i)=0
end do
c
c Extend the graph with n-m0 node
c
do i=m0+1,n
linked(:i)=.false.
c
c Add edges while the vertex degree of the ith node is less than m
c
do
if(sum(kon(i,:i-1)).eq.m) exit
ii=floor(dble(i-1)*ran1(idum))+1
if(.not.linked(ii)) then
p=(dble(sum(kon(ii,:i-1)))/sum(kon(:i-1,:i-1)))**a
if(p.gt.ran1(idum)) then
kon(i,ii)=1
kon(ii,i)=1
linked(ii)=.true.
endif
endif
end do
end do
end

一些链接连接到:

https://math.stackexchange.com/questions/454188/why-does-my-barabasi-albert-model-implementation-doesnt-produce-a-scale-free-ne

https://math.stackexchange.com/questions/1824097/creating-barab%c3%a1si-albertba-graph-with-spacific-node-and-edgs

Implementing Barabasi-Albert Method for Creating Scale-Free Networks

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com