[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] add vertex label shortest path
From: |
joe j |
Subject: |
Re: [igraph] add vertex label shortest path |
Date: |
Thu, 30 Jun 2011 10:21:21 +0200 |
OK. I seem to have found a solution, but any improvement (or if you
find something wrong with the steps) is welcome :)
I created an adjacency matrix using the same graph-in this case column
and row names are node names, which is great. Then I replaced column
names and row names in my shortest path matrix, after converting both
matrices into 'diad' formw with three columns. So the steps are:
> y_s<-shortest.paths(y, weights = NULL)
> y_s <- melt(y_s)[melt(upper.tri(y_s))$value,]
>a <- get.adjacency(y)
>a <- melt(a)[melt(upper.tri(a))$value,]
#replace column names in shortest path with column names in the adjacency matrix
>y_s$X1<-a$X1
>y_s$X2<-a$X2
Cheers,
Joe.