igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Diameter vs. longest shortest paths


From: Tamas Nepusz
Subject: Re: [igraph] Diameter vs. longest shortest paths
Date: Tue, 08 Mar 2011 11:11:56 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8

> a) The diameter takes the directness of a graph into account, the 
> shortest.path don't (see case 1 and 2 below)
> b) The diameter and the shortest.path takes the weight of an edge into 
> account by adding the weights of each edge (see case 3 and 4).  
>
> Are both insights correct?
Yes, they are. I'd add some clarification though. Both functions *can*
take the directedness of a graph into account, but there are two caveats:

1. You have to pass mode="out" to shortest.paths() if you are interested
in directed paths; mode="all" is the default which considers edges as
undirected.

2. diameter() and shortest.paths() behave differently when the graph is
not strongly connected (like in your case). For instance, in your second
example, it is impossible to reach vertex 8 from vertex 3. In such
cases, diameter() calculates the diameter of the largest connected
component and returns that (check out the "unconnected" parameter in
help(diameter)), while shortest.paths() uses a value of infinity (if I
remember correctly).

Regarding weights: if you have a "weight" attribute, then diameter() and
shortest.paths() will use that. If you want to use some other edge
attribute or an arbitrary vector as weights, you can pass that in the
weights=... argument.

-- 
T.



reply via email to

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