[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] betweenness centrality for weighted graphs

From: T.O. Richardson
Subject: [igraph] betweenness centrality for weighted graphs
Date: Tue, 29 Mar 2011 22:09:25 +0100

Hi List,
Please see correspondence below for the calculation of weighted betweenness in igraph.

On Tue, Mar 29, 2011 at 9:11 AM, T.O. Richardson
<address@hidden> wrote:
Hi Gábor & Tamas,
I have a query about igraph in R.
I have a dynamic undirected weighted graph and would like to calculate the
betweenness centrality for each vertex at each time-point.
However, the betweenness function in igraph version 0.5.5-2 does not seem
take into account the edge weights.

My code is:
actors <- data.frame(name=ants))
relations <- data.frame(from=fromm, to=too )
net <-graph.data.frame(relations, directed=FALSE, vertices=actors)
E(net)$weight <- weights
betweenness(net, V(net), directed=FALSE)

The resulting betweenness from the above is identical irrespective of
whether you add the weights to the edges, or not.

I looked at the CRAN changelog, where it states (i think) that the file
"interfaces/R/igraph/R/structural.properties.R" has been modified (on
2009-08-02 14:04:01) to include edge weighting.
If I try to simply cut & paste the code (that should take weights into
account) for the betweenness function from the CRAN change-log (see
then I get the error 'could not find function "as.igraph.vs" ' . I can't
interpret the C code in the changelog, so i am abit lost..

Many Thanks,
Tom Richardson

## code from the CRAN igraph change-log:
betweenness <- function(graph, v=V(graph), directed=TRUE, weights=NULL,
                      verbose=igraph.par("verbose")) {
verbose=igraph.par("verbose")) {

 if (!is.igraph(graph)) {
   stop("Not a graph object")
 on.exit( .Call("R_igraph_finalizer", PACKAGE="igraph") )
 .Call("R_igraph_betweenness", graph, as.igraph.vs(graph, v),
      as.logical(directed), weights, as.logical(verbose),
      as.logical(directed), weights, as.logical(nobigint),

Dear Tom,

please send these kind of questions to the igraph-help mailing list,
see http://igraph.sf.net. Thanks!

As for your question, indeed, weighted betweenness is only implemented
in the 0.6 development version. Copying the R code from 0.6 does not
help, because the implementation is in C.

You can download the 0.6 version from
Go for igraph_nightly_0.6-2410-20110328.tar.gz, because the newest
version does not work properly.
This is an R source package, which works on Linux or OSX (if you can
compile C/C++ programs on OSX). If you need a windows package, then I
can send you one.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]