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