igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] layout repeatability in R ?


From: Gábor Csárdi
Subject: Re: [igraph] layout repeatability in R ?
Date: Thu, 22 Apr 2010 11:26:20 +0200

Dear Olivier,

On Wed, Apr 21, 2010 at 10:49 PM, Olivier Delrieu <address@hidden> wrote:
> Dear All,
>
> I am wondering how to achieve layout repeatability with igraph in R,
> especially with the Kamada-Kawai and Fruchterman-Reingold algorithms? By
> this I mean ability to produce the same result given fully specified
> starting conditions.

I agree that repeatability is nice in general. But in this case, can't
you just simply save the calculated coordinates and pass them along,
together with the graph?

Anyway, you can get the same results, just set the seed of the random
number generator:

library(igraph)
g <- graph.de.bruijn(5,2)

set.seed(123)
coord <- layout.kamada.kawai(g)

set.seed(123)
coord2 <- layout.kamada.kawai(g)

max(abs(coord - coord2))

> This is quite important when exchanging data & results with other
> researchers. Also, Kamada-Kawai can be used for quickly generating an
> advantageous initial layout which can be passed to Fruchterman-Reingold
> for a visually more significant placement of neighbored nodes.
>
> The code below shows this is not the case with layout.drl despite
> providing seed coordinates to the algorithm. Am I missing something?

I think this just shows that the DrL algorithm is stochastic. Plus,
even if started from the same initial positions, you get different
results.

> Regarding Kamada-Kawai, and Fruchterman-Reingold the C++ code shows
> initial configuration can be provided with 'use_seed' and 'res', but
> these parameters are not documented in the R equivalent. See:
> http://igraph.sourceforge.net/doc/html/igraph_layout_kamada_kawai.html
> http://igraph.sourceforge.net/doc/html/igraph_layout_fruchterman_reingold.html
> http://igraph.sourceforge.net/doc/R/layout.html

Indeed, I'll fix this.

Best,
Gabor

>
> R code:
>
> library(igraph)
> g <- graph.de.bruijn(5,2)
> coord <- layout.kamada.kawai(g)
> coord2 <- layout.drl(g, use.seed=TRUE, seed=coord)
> coord3 <- layout.drl(g, use.seed=TRUE, seed=coord)
> X11()
> plot(g,layout=coord2)
> X11()
> plot(g,layout=coord3)
>
>
> Many thanks,
>
> Olivier.
>
>
> _______________________________________________
> 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]