igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Question about layout algorithm


From: Gábor Csárdi
Subject: Re: [igraph] Question about layout algorithm
Date: Fri, 4 Nov 2011 11:08:05 -0400

On Fri, Nov 4, 2011 at 9:45 AM, address@hidden
<address@hidden> wrote:
> Hi,
>
> I have adjacency matrix "A" and weights matrix "W", both are symmetric and I
> want to create udirected graph from them.
>
> I can make a simple graph by
>
> g = graph.adjacency(A,mode=c("undirected"), diag=F)
> tkplot(g,layout = layout.fruchterman.reingold)
>
> The problem is that I would like compute layout with with force-based
> algorithm taking into account weights of both edges and non-edges, and use
> that layout to display network with only edges.
>
> Does anyone know how to do that ? I would be grateful for example. Thanks.

Here is an example.

W <- matrix(runif(100), 10)
W <- W+t(W)
W[ W<0.6 ] <- 0

g <- graph.adjacency(W, mode="undirected", weighted=TRUE, diag=F)
coords <- layout.fruchterman.reingold(g, weights=E(g)$weight)
plot(g, layout=coords, vertex.shape="none", vertex.label=NA, vertex.size=0)

G.

>
> _______________________________________________
> 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]