代码拉取完成,页面将自动刷新
同步操作将从 连享会/nwcommands 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
*! Date : 24aug2014
*! Version : 1.0.4
*! Author : Thomas Grund, Linkoping University
*! Email : contact@nwcommands.org
* Calculates actor closeness centrality according to Sabidussi (1966)
* See Wassermann & Faust (1994, p. 184)
capture program drop nwcloseness
program nwcloseness
version 9
syntax [anything(name=netname)] [, GENerate(string) *]
_nwsyntax `netname', max(9999)
if `networks' > 1 {
local k = 1
}
_nwsetobs `netname'
local gencount : word count `generate'
if (`gencount' != 3) {
local generate = "_closeness _farness _nearness"
}
local generate_all ""
set more off
qui foreach netname_temp in `netname' {
preserve
qui nwgeodesic `netname_temp', name(_tempgeodesic) `options' xvars
nwname _tempgeodesic
nwtomata _tempgeodesic, mat(geodesic)
mata: st_numscalar("r(mindistance)", min(geodesic))
mata: far = rowsum(geodesic)
if `r(mindistance)' < 0 {
mata: far = J(rows(geodesic), 1, .)
noi di "{txt}Warning: network {bf:`netname_temp'} not connected; specify {bf:unconnected()} to obtain results.
nwdrop _tempgeodesic
exit
}
_nwsyntax_other `netname_temp'
mata: nearness = J(`othernodes', 1,1) :/ far
mata: closeness = nearness :* (`othernodes' - 1)
local _closeness : word 1 of `generate'
local _farness : word 2 of `generate'
local _nearness : word 3 of `generate'
nwdrop _tempgeodesic
restore
_nwsetobs `netname_temp'
qui capture drop `_closeness'`k'
qui gen `_closeness'`k' = .
qui capture drop `_farness'`k'
qui gen `_farness'`k' = .
qui capture drop `_nearness'`k'
qui gen `_nearness'`k' =.
mata: st_store((1::`othernodes'),"`_closeness'`k'",closeness)
mata: st_store((1::`othernodes'),"`_farness'`k'",far)
mata: st_store((1::`othernodes'),"`_nearness'`k'",nearness)
local generate_all "`generate_all' `_closeness'`k' `_farness'`k' `_nearness'`k'"
mata: mata drop closeness far nearness geodesic
local k = `k' + 1
}
mata: st_rclear()
di "{hline 40}"
di "{txt} Network name: {res}`netname'"
di "{hline 40}"
di "{txt} Closeness centrality"
sum `generate_all'
end
*! v1.5.0 __ 17 Sep 2015 __ 13:09:53
*! v1.5.1 __ 17 Sep 2015 __ 14:54:23
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。