关于igraph中的介数函数

关于igraph中的介数函数,r,igraph,R,Igraph,当我们使用'betweenness'函数betweenness(g,weights=NULL,directed=FALSE)时,如果图形具有weight属性,即使我们写入weights=NULL,该函数仍将使用weight属性计算betweenness。但是我想计算不带权重属性的中间值。所以我认为这个函数看起来很奇怪。为什么在写入weights=NULL时它仍然使用weight属性 function (graph, v = V(graph), directed = TRUE, weights =

当我们使用'betweenness'函数betweenness(g,weights=NULL,directed=FALSE)时,如果图形具有weight属性,即使我们写入weights=NULL,该函数仍将使用weight属性计算betweenness。但是我想计算不带权重属性的中间值。所以我认为这个函数看起来很奇怪。为什么在写入weights=NULL时它仍然使用weight属性

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
}
函数(图,v=v(图),directed=TRUE,weights=NULL,
nobigint=TRUE,normalized=FALSE)
{
如果(!is.igraph(graph)){
停止(“不是图形对象”)
}

v权重选项不是关于忽略和不使用权重。它是关于为用户提供选项以提供自己的权重向量

权重-用于计算加权中间值的可选正权重向量。如果图形具有权重边属性,则默认情况下使用该属性

因此,如果
weights=NULL
函数将默认使用
E(g)$weight

自己做这件事的方法是移除砝码或将其设置为1,例如

E(g)$weight <- 1

E(g)$weight权重向量应该如何排序?我如何知道权重向量的哪个元素对应于图中的哪个边?权重向量与边的存储顺序相同。如
E(g)