[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] closeness and average path length in terms of the harmonic
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] closeness and average path length in terms of the harmonic distance between vertices |
Date: |
Thu, 7 Mar 2013 12:22:19 +0100 |
Hi Bob,
> Sorry I only come back to you only now. shortest.paths does not seem to
> indicate the vertices that have been traversed in the shortest paths - just a
> matrix of those shortest paths.
Yup, but you can use get.shortest.paths() to get _one_ shortest path per vertex
pair, or get.all.shortest.paths() to get _all_ possible shortest paths between
vertices. Of course the output of the latter function can be huge, especially
if the graph has a regular structure (like a lattice) and there are many
shortest paths between the same pair of vertices.
> Having looked at closeness(), is seems that closeness is currently done as:
> res <- .Call("R_igraph_closeness", graph, vids - 1, mode, weights, PACKAGE =
> "igraph")
>
> How do I learn more of what is being done by this function? Many thanks.
It goes down to the C core of igraph, where it eventually ends up in a function
named igraph_closeness:
http://igraph.sourceforge.net/doc/html/ch13s06.html#igraph_closeness
The source code is here:
https://github.com/igraph/igraph/blob/master/src/centrality.c#L2565
However, this function requires extensive knowledge of the C layer of igraph,
so I don't know how useful it will be to you in the end. It boils down to doing
a breadth first search on the graph and recording the distances in a vector.
--
T.