gpt4 book ai didi

r - 如何构建新的中心性度量?

转载 作者:行者123 更新时间:2023-12-01 11:49:33 26 4
gpt4 key购买 nike

我想使用 igraph 构建一个新的中心性度量,最好是在 R 中。

我该如何开始呢?

例如,添加到 igraph C 库 还是添加到 R 接口(interface) 会更好?

最佳答案

这实际上归结为您的舒适程度。也就是说,igraph 主要是一个 C 库(您可以 browse all the source code on sourceforge ),因此扩展它的最合乎逻辑的方式可能是在 C 中。例如,R 中的 closeness 函数只是调用相关的 C 函数:

> closeness
function (graph, v = V(graph), mode = c("all", "out", "in"))
{
if (!is.igraph(graph)) {
stop("Not a graph object")
}
mode <- igraph.match.arg(mode)
mode <- switch(mode, out = 1, `in` = 2, all = 3)
on.exit(.Call("R_igraph_finalizer", PACKAGE = "igraph"))
.Call("R_igraph_closeness", graph, as.igraph.vs(v), as.numeric(mode),
PACKAGE = "igraph")
}

这里是 the existing centrality sourcecode .

关于r - 如何构建新的中心性度量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1810650/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com