代码拉取完成,页面将自动刷新
*! Date : 3sept2014
*! Version : 1.0.1
*! Author : Thomas Grund, Linkping University
*! Email : contact@nwcommands.org
capture program drop nwexport
program nwexport
version 9
syntax [anything(name=netname)], type(string) [FName(string asis) replace]
_nwsyntax `netname', max(1)
_opts_oneof "pajek ucinet" "type" "`type'" 6810
if `"`fname'"' == "" {
local fname = "`netname'"
}
di `"{txt}Exporting network: {it:`netname'}"'
if "`type'" == "pajek" {
_nwexport_pajek `netname', fname(`fname') `replace'
}
if "`type'" == "ucinet" {
_nwexport_ucinet `netname', fname(`fname') `replace'
}
end
capture program drop _nwexport_pajek
program _nwexport_pajek
syntax [anything(name=netname)], fname(string) [replace]
nwname `netname'
local vars "`r(vars)'"
local labs "`r(labs)'"
local directed "`r(directed)'"
local nodes `r(nodes)'
tempname expfile
file open `expfile' using "`fname'.net", write `replace'
file write `expfile' "*Vertices `nodes'" _newline
forvalues i = 1/`nodes' {
local onelab : word `i' of `labs'
file write `expfile' (`i')
file write `expfile' (" ")
file write `expfile' (char(34))
file write `expfile' ("`onelab'")
file write `expfile' (char(34)) _newline
}
if ("`directed'" == "true"){
file write `expfile' "*Arcs"
}
else {
file write `expfile' "*Edges"
}
preserve
qui nwtoedge `netname'
qui keep if `netname' != 0
local ties = _N
forvalues i = 1/`ties' {
if `netname'[`i'] != 0 {
local value = `netname'[`i']
local k = _fromid[`i']
local l = _toid[`i']
file write `expfile' _newline
file write `expfile' (`k')
file write `expfile' " "
file write `expfile' (`l')
file write `expfile' " `value'"
}
}
file write `expfile' "" _newline
file close `expfile'
restore
end
capture program drop _nwexport_ucinet
program _nwexport_ucinet
syntax [anything(name=netname)], fname(string) [replace]
nwname `netname'
local vars "`r(vars)'"
local labs "`r(labs)'"
local directed "`r(directed)'"
local nodes `r(nodes)'
tempname expfile
file open `expfile' using "`fname'.dl", write `replace'
file write `expfile' "dl n=`nodes'" _newline
file write `expfile' "labels:" _newline
forvalues i = 1/`nodes' {
local onelab : word `i' of `labs'
file write `expfile' ("`onelab'")
if `i' < `nodes' {
file write `expfile' (",")
}
}
file write `expfile' _newline
file write `expfile' "data:"
preserve
qui nwtoedge `netname'
qui keep if `netname' != 0
local ties = _N
forvalues i = 1/`ties' {
if `netname'[`i'] != 0 {
local value = `netname'[`i']
local k = _fromid[`i']
local l = _toid[`i']
file write `expfile' _newline
file write `expfile' (`k')
file write `expfile' " "
file write `expfile' (`l')
file write `expfile' " `value'"
}
}
file close `expfile'
restore
end
*! v1.5.0 __ 17 Sep 2015 __ 13:09:53
*! v1.5.1 __ 17 Sep 2015 __ 14:54:23
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。