[Top][All Lists]

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

Re: [igraph] add vertex label shortest path

From: Tamas Nepusz
Subject: Re: [igraph] add vertex label shortest path
Date: Thu, 30 Jun 2011 10:38:20 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10

Hi Joe,

Assuming that your graph is y and it has a "name" attribute containing the
vertex names, V(y)$name gives you the name of each vertex. You can then
index this list with the first column of y_s to remap the indices to names:

y_s[,1] <- V(y)$name[y_s[,1]]

Similarly for the second column:

y_s[,2] <- V(y)$name[y_s[,2]]


On 06/29/2011 02:52 PM, joe j wrote:
> #code for generating shortest path matrix and creating a 3 columns
> y_s<-shortest.paths(y,  weights = NULL)
> y_s <- melt(y_s)[melt(upper.tri(y_s))$value,]
> names(y_s) <- c("vertex1", "vertex2", "shortestpath")

reply via email to

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