1
当我们使用'betweenness'函数betweenness(g,weights = NULL,directed = FALSE)时,如果图形具有weight属性,即使我们编写weights = NULL,函数也会仍然使用weight属性来计算介词。但是我想计算没有weight属性的中间值。所以我觉得这个功能看起来很奇怪。为什么我们在编写weights = NULL时仍然使用weight属性?关于igraph中介函数
function (graph, v = V(graph), directed = TRUE, weights = NULL,
nobigint = TRUE, normalized = FALSE)
{
if (!is.igraph(graph)) {
stop("Not a graph object")
}
v <- as.igraph.vs(graph, v)
if (is.null(weights) && "weight" %in% list.edge.attributes(graph)) {
weights <- E(graph)$weight
}
if (!is.null(weights) && any(!is.na(weights))) {
weights <- as.numeric(weights)
}
else {
weights <- NULL
}
on.exit(.Call("R_igraph_finalizer", PACKAGE = "igraph"))
res <- .Call("R_igraph_betweenness", graph, v - 1, as.logical(directed),
weights, as.logical(nobigint), PACKAGE = "igraph")
if (normalized) {
vc <- vcount(graph)
res <- 2 * res/(vc * vc - 3 * vc + 2)
}
if (getIgraphOpt("add.vertex.names") && is.named(graph)) {
names(res) <- V(graph)$name[v]
}
res
}
谢谢! user1317221_G – Ben 2013-04-22 01:07:04
权重向量应该如何排序?我如何知道权向量的哪个元素对应于图中的哪条边? – Szabolcs 2014-04-17 20:04:53
权重向量与边缘存储的顺序相同。如'E(g)' – 2014-04-20 18:44:01