igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Betweenness centrality for specific origin and destination


From: Gábor Csárdi
Subject: Re: [igraph] Betweenness centrality for specific origin and destination
Date: Mon, 4 May 2009 15:01:36 +0200

Aisan,

this is quite special, so we don't support it out-of-the-box, but you
can do it "by hand":

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
}

It does not do any normalization, just returns the (weighted) number
of paths that goes through a given vertex, but only considering the
paths from 'source' to 'targets'. 'source' must be a single vertex,
call it multiple times for multiple sources.

I haven't tested it thoroughly.

Best,
G.

On Mon, May 4, 2009 at 1:50 AM, Aisan Kazerani
<address@hidden> wrote:
> Hi,
>
> I'm working on the betweenness centrality of a transportation network. I'd
> like to know whether igraph is capable of accepting specific origin and
> destination nodes for computing betweenness centrality instead of
> calculating betwns by finding shortest path from each node to every node?
> For example betwens centrality of a 10 node network with paths from 1 to
> 8, 3 to 6 and etc (origins:1, 3 and destinations:8, 6).
> I know that it can compute shortest path for specific nodes but not sure
> about betwns as well!
>
> Thank you very much in advance for answering all the questions so
> patiently...
>
> 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]