igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Edge betweenness centrality for specific Origin-Destinatio


From: Gábor Csárdi
Subject: Re: [igraph] Edge betweenness centrality for specific Origin-Destination
Date: Wed, 6 May 2009 17:13:26 +0200

Aisan,

here is a version that does it for the edges:

ebw.fromto <- function(graph, source, targets=V(graph)) {
  ebw <- numeric(ecount(graph))
  paths <- get.all.shortest.paths(graph, source, targets)
  last <- sapply(paths, tail, 1)
  freq <- table(last)[ as.character(last) ]

  for (i in seq_along(paths)) {
    ee <- E(graph, path=paths[[i]])
    ebw [ ee + 1 ] <- ebw[ ee + 1 ] + 1/freq[i]
  }
  ebw
}

Again, I haven't tested it extensively.

Btw. some people consider it offensive if you send basically the same
email twice to the same list.

G.

On Tue, May 5, 2009 at 6:13 AM, Aisan Kazerani
<address@hidden> wrote:
> Dear Gabor,
>
> Thanks for your helpful guide. I managed to compute betweenness centrality
> for specific origin and destination with your code:
>
> bw.fromto <- function(graph, source, targets=V(graph)) {
>  bw <- numeric(vcount(graph))
>  paths <- get.all.shortest.paths(graph, source, targets)
>  last <- sapply(paths, tail, 1)
>  freq <- table(last)[ as.character(last) ]
>  red.paths <- sapply(paths, function(x) x[c(-1,-length(x))])
>  for (i in seq_along(red.paths)) {
>     bw[ red.paths[[i]]+1] <- bw[ red.paths[[i]] + 1] + 1/freq[i]
>  }
>  bw
> }
> Do you think I would be able to compute edge betweenness centrality for
> the same case?
>
> Thank you very much again...
>
> Cheers,
> Aisan
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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