igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Alpha centrality with valued graphs


From: Brandon J. Kinne
Subject: Re: [igraph] Alpha centrality with valued graphs
Date: Sun, 01 Feb 2009 12:26:27 -0500
User-agent: Internet Messaging Program (IMP) H3 (4.0.3)

Dear Gabor:

Thanks very much for the quick response. I believe you're correct that
alpha centrality for valued graphs just uses the weighted adjacency
matrix. I used the function you provided, but I always receive the same
error code:

"Error in get.adjacency.dense(graph, type = type, attr = attr, names =
names,  :
 no such edge attribute"

I've specified edge weights simply as E(graph)$weight, but I always
receive the same error. As well, assigning weights to a separate R
object (for example, w <- as.vector(E(graph)$weight)) and using that as
the attributes produces the same error.

Is this a problem with attr part of the modified alpha.centrality
function, or am I just not specifying edge weights correctly?

Here's an example of my code: alph <- matrix(alpha.centrality(gr,
alpha=m, loops=F, exo=1, attr=E(gr)$weight))

where m is based on the eigenvalues of the adjacency matrix.

Thanks again for your help.

Best regards,

Brandon


Quoting Gábor Csárdi <address@hidden>:

How exactly is 'weighted' alpha centrality defined? Is it just that we
use the "weighted" adjacency matrix instead of the regular one. If
yes, then I've added this to the development version. Here is the
modified function, you can use it before the new igraph is released.

Best,
Gabor

alpha.centrality <- function(graph, nodes=V(graph), alpha=1,
                            loops=FALSE, exo=1, attr=NULL,
                            tol=1e-7) {
 if (!is.igraph(graph)) {
   stop("Not a graph object")
 }

 exo <- rep(exo, length=vcount(graph))
 exo <- matrix(exo, nc=1)

 d <- t(get.adjacency(graph, attr=attr))
 if (!loops) {
   diag(d) <- 0
 }
 n <- vcount(graph)
 id <- matrix(0, nrow=n, ncol=n)
 diag(id) <- 1

 ev <- solve(id-alpha*d, tol=tol) %*% exo
 ev[as.numeric(nodes)+1]
}

On Sun, Jan 25, 2009 at 8:39 PM, Brandon J Kinne
<address@hidden> wrote:
Dear all:

Bonacich's 2001 paper mentions that alpha centrality can be calculated not
only on directed, but also valued graphs. However, I can't seem to get
igraph to consider edge weights when using alpha.centrality. Am I missing
something here, or does igraph simply not allow valued graphs with
alpha.centrality? I know there is other software, such as UciNet, that does
calculate alpha centrality for valued graphs, but I'd much prefer to stay
within the R environment. Thanks in advance for the help!

Best regards,

Brandon Kinne


_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help




--
Gabor Csardi <address@hidden>     UNIL DGM


_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help




--
Brandon J. Kinne
Yale University
Department of Political Science
124 Prospect Street
New Haven, Connecticut 06520




reply via email to

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