igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] to attach edge weights


From: MATSUDA, Noriyuki
Subject: Re: [igraph] to attach edge weights
Date: Thu, 29 Nov 2007 17:30:52 +0900

Hi Gabor:

  Thanks a lot.  Yes, it works.

At 8:50 AM +0100 07.11.29, Gabor Csardi wrote:
The easiest is to use the 'weighted' argument of graph.adjacency:

m<- rbind(c(1, 0.2, 0.6), c(0.2, 1, 0.8), c(0.6, 0.8, 1))
diag(m) <- 0
m[ m<0.5 ] <- 0
g <- graph.adjacency(m, weighted=TRUE)

Although i just noticed that 'weighted' and 'upper' don't work
well together, so if you want to create an undirected graph
here is a workaround:

m<- rbind(c(1, 0.2, 0.6), c(0.2, 1, 0.8), c(0.6, 0.8, 1))
diag(m) <- 0
m[ m<0.5 ] <- 0
m[ lower.tri(m) ] <- 0
g <- graph.adjacency(m, weighted=TRUE, mode="undirected")

Gabor

On Thu, Nov 29, 2007 at 11:42:36AM +0900, MATSUDA, Noriyuki wrote:
 Hello:

    I'd be happy if any one can tell me how to attach edge weights on
 the basis of a connectedness/similarity matrix.  Suppose I do the
 following for a 3 by 3 correlation matrix
    m<- rbind(c(1, 0.2, 0.6), c(0.2, 1, 0.8), c(0.6, 0.8, 1))
    m(diag)<-NA;
    m[m(a)<0.5] <-0;  m[m(a)>=0.5] <-1  #There must be a better way
    g<-graph.adjacency(m, mode="upper"] #upper includes diagonals
    E(g)$weight ???????

 Thanks in advance
 --
 MATSUDA, Noriyuki <in Kanji> 松 田 紀 之


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

--
Csardi Gabor <address@hidden>    MTA RMKI, ELTE TTK


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


--
MATSUDA, Noriyuki <in Kanji> 松 田 紀 之




reply via email to

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