1 Star 1 Fork 7

连享会/nwcommands

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
nwrecode.ado 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
ThomasGrund 提交于 2015-09-18 19:13 . v1.5.1
capture program drop nwrecode
program nwrecode
version 9
syntax anything(name=arg) [, into(string) generate(string) prefix(string) *]
if "`arg'" == "" {
exit
}
if "`into'" != "" {
local generate "`into'"
}
local ruleStart = strpos("`arg'", "(")
local netname = substr("`arg'",1, `=`ruleStart'-1')
local rules = substr("`arg'",`ruleStart',.)
_nwsyntax_other `netname', max(9999)
preserve
tokenize `generate'
local i = 1
foreach onenet in `othernetname' {
_nwsyntax `onenet'
local onedirected `directed'
nwtoedge `onenet', forcedirected
recode `onenet' `rules', `options'
qui nwfromedge _fromid _toid `onenet', name(__temp_network)
nwtomata __temp_network, mat(recodeNet)
if "`generate'" == "" & "`prefix'" == "" {
nwreplacemat `onenet', newmat(recodeNet)
}
else {
if "`prefix'" != "" {
nwduplicate `onenet', name(`prefix'`onenet')
nwreplacemat `prefix'`onenet', newmat(recodeNet)
}
if "`generate'" != "" {
if "``i''" != "" {
nwduplicate `onenet', name(``i'')
nwreplacemat ``i'', newmat(recodeNet)
}
else {
nwreplacemat `onenet', newmat(recodeNet)
}
}
}
capture nwdrop __temp_network
mata: mata drop recodeNet
local i = `i' + 1
nwname `onenet', newdirected(`onedirected')
}
restore
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/arlionn/nwcommands.git
git@gitee.com:arlionn/nwcommands.git
arlionn
nwcommands
nwcommands
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385