1 Star 0 Fork 7

夏汉林/nwcommands

forked from 连享会/nwcommands 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
nwcurrent.ado 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
ThomasGrund 提交于 2015-09-18 19:13 . v1.5.1
*! Date : 24aug2014
*! Version : 1.0
*! Author : Thomas Grund, Linkoping University
*! Email : contact@nwcommands.org
capture program drop nwcurrent
program nwcurrent
syntax [anything(name=netname)] [,id(string)]
// Set a new current network.
if "`id'" != "" | "`netname'" != "" {
if ("`id'" != "") {
nwname, id(`id')
}
else {
_nwsyntax `netname', max(1)
nwname `netname'
}
local j = r(id)
local i = $nwtotal
// Exchange networks i and j
// Get info from network j
scalar tonevars_j = "\$nw_`j'"
scalar tonelabs_j = "\$nwlabs_`j'"
local tname_j = r(name)
local tdirected_j = r(directed)
local tsize_j = r(nodes)
local tvars_j `=tonevars_j'
local tlabs_j `=tonelabs_j'
mata: tnet_j = nw_mata`j'
// Get info from network i
scalar onename = "\$nwname_`i'"
scalar onenw = "\$nw_`i'"
scalar onedirected = "\$nwdirected_`i'"
scalar onesize = "\$nwsize_`i'"
scalar onelabs = "\$nwlabs_`i'"
scalar oneedgelabs = "\$nwedgelabs_`i'"
local tlabs_i `"`=onelabs'"'
local tedgelabs_i `"`=oneedgelabs'"'
local tname_i `=onename'
local tvars_i `=onenw'
local tsize_i `=onesize'
local tdirected_i `=onedirected'
mata: tnet_i = nw_mata`i'
// Set new networks
global nwname_`i' `tname_j'
global nw_`i' `tvars_j'
global nwdirected_`i' `tdirected_j'
global nwsize_`i' `tsize_j'
global nwlabs_`i' `"`tlabs_j'"'
global nwedglabs_`i' `"`tedgelabs_j'"'
mata: nw_mata`i' = tnet_j
global nwname_`j' `tname_i'
global nw_`j' `tvars_i'
global nwdirected_`j' `tdirected_i'
global nwsize_`j' `tsize_i'
global nwlabs_`j' `"`tlabs_i'"'
global nwedgelabs_`j' `"`tedgelabs_i'"'
mata: nw_mata`j' = tnet_i
mata: mata drop tnet_i tnet_j
}
// Populate return vector.
nwset, nooutput
local i = $nwtotal
scalar onename = "\$nwname_`i'"
local localname `=onename'
mata: st_rclear()
mata: st_global("r(current)", "`localname'")
mata: st_numscalar("r(networks)", $nwtotal)
end
*! v1.5.0 __ 17 Sep 2015 __ 13:09:53
*! v1.5.1 __ 17 Sep 2015 __ 14:54:23
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiahanlin/nwcommands.git
git@gitee.com:xiahanlin/nwcommands.git
xiahanlin
nwcommands
nwcommands
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385