igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] weighting fruchterman reingold plots and extracting resulti


From: Gábor Csárdi
Subject: Re: [igraph] weighting fruchterman reingold plots and extracting resulting coordinates
Date: Tue, 2 Oct 2012 11:13:06 -0400

Hi!

On Tue, Oct 2, 2012 at 10:22 AM, Paul Smith
<address@hidden> wrote:
[...]
> g <- graph.data.frame(AllData)
>
> new_g <- layout.fruchterman.reingold(g, dist=NULL, dim=2,
> options=igraph.arpack.default)

some misunderstanding here I think. layout.fruchterman.reingold does
not create a graph, it calculates the coordinates of the vertices and
returns them in a two-column matrix.

> plot(new_g, layout=layout.fruchterman.reingold, vertex.size=10,
> vertex.label=NA)
>
>
>
> How can I weigh the distances between points

Supply the 'weights' argument to layout.fruchterman.reingold.

> and output the resulting
> coordinates so they can be input into another graphing package?

Just use the output of layout.fruchterman.reingold. E.g. 'coords' here:

g <- graph.ring(10)
E(g)$weight <- c(1,2)
str(g, e=T)
# IGRAPH U-W- 10 10 -- Ring graph
# + attr: name (g/c), mutual (g/l), circular (g/l), weight (e/n)
# + edges and their attributes:
#       edge weight
# [1]   1-- 2      1
# [2]   2-- 3      2
# [3]   3-- 4      1
# [4]   4-- 5      2
# [5]   5-- 6      1
# [6]   6-- 7      2
# [7]   7-- 8      1
# [8]   8-- 9      2
# [9]   9--10      1
# [10]  1--10      2

coords <- layout.fruchterman.reingold(g, weights=E(g)$weight)
plot(g, layout=coords)

Best,
Gabor

>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     MTA KFKI RMKI



reply via email to

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