1 Star 1 Fork 7

连享会/nwcommands

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
nwpermute.ado 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
ThomasGrund 提交于 2015-09-18 19:13 . v1.5.1
*! Date : 3sept2014
*! Version : 1.0.4
*! Author : Thomas Grund, Linkoping University
*! Email : contact@nwcommands.org
capture program drop nwpermute
program nwpermute
version 9.0
syntax [anything(name=netname)], [ id(string) xvars name(string) vars(string) stub(string) noreplace ]
_nwsyntax `netname', max(1)
scalar onevars = "\$nw_`id'"
local vars `=onevars'
// generate valid network name and valid varlist
if "`name'" == "" {
local name "`netname'_perm"
}
if "`stub'" == "" {
local stub "perm"
}
nwvalidate `name'
local name = r(validname)
local varscount : word count `vars'
if (`varscount' != `nodes'){
nwvalidvars `nodes', stub(`stub')
local permvars "$validvars"
}
else {
local permvars "`vars'"
}
nwtomata `netname', mat(onenet)
mata: perm = permutenet(onenet)
if "`directed'"=="false" {
local undirected = "undirected"
}
nwduplicate `netname', name(`name')
nwreplacemat `name', newmat(perm)
end
capture mata mata drop permutenet()
mata:
real matrix permutenet(real matrix nwadj) {
nsize = rows(nwadj)
permutationVec = unorder(nsize)
return (nwadj[permutationVec, permutationVec])
}
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