igraph-help
[Top][All Lists]

[igraph] Re: average path length

 From: Alisa Coffin Subject: [igraph] Re: average path length Date: Fri, 11 Dec 2009 11:27:38 -0700

Dear Gabor,

Can you look at the following and suggest what I may be doing wrong here? I would expect for the undirected, connected graph (g1975_1un) to have an average path length value about 2x the value for the directed, unconnected graph (g1975), based on your previous message (also below). However, the only difference appears to be due to the fact that the connected graph is the first (and largest) subcomponent of the unconnected graph, but not a real difference (for g1975, v=5162; for g1975_1un, v=5103).

By the way, when I summed all the shortest paths and divided it by the number of geodesics for the undirected, connected graph (g1975_1un), I got the value of 87.63352, which is what I would expect. However, "average.path.length" still gives me half of that value, as though it were using the n(n-1) value for directed graphs even though the graph is undirected.

Can you help?

Thanks, Alisa.

> is.directed(g1975)
[1] TRUE
> is.connected(g1975)
[1] FALSE
> average.path.length(g1975, directed=TRUE)
[1] 43.81249
> average.path.length(g1975, directed=TRUE, unconnected=TRUE)
[1] 43.81249

> is.directed(g1975_1un)
[1] FALSE
> is.connected(g1975_1un)
[1] TRUE
> average.path.length(g1975_1un, directed=FALSE)
[1] 43.81676
> average.path.length(g1975_1un, directed=FALSE, unconnected=FALSE)
[1] 43.81676

Message: 4
Date: Wed, 9 Dec 2009 19:45:51 +0100
Subject: Re: [igraph] average path length
To: Help for igraph users <address@hidden>
Message-ID:
Content-Type: text/plain; charset=ISO-8859-1

Hi Alisa,

it is the average of all path lengths if the graph. This means
n(n-1)/2 paths in undirected graphs or if the 'directed' argument is
FALSE, and n(n-1) paths in directed graphs when the 'directed'
argument is TRUE.

For unconnected (or not strongly connected) graphs see the
'unconnected' argument.

G.

Alisa Coffin, PhD
2741 Kansas Drive #106
Fort Collins, CO  80525

phone: 1.352.283.5393