igraph-help
[Top][All Lists]
Advanced

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

[igraph] add vertex label shortest path


From: joe j
Subject: [igraph] add vertex label shortest path
Date: Wed, 29 Jun 2011 14:52:57 +0200

This would be a straight forward thing to do, but I can't figure out how.

Basically I want the output of 'shortest.paths' in three columns:
"vertex1", "vertex2", "shortestpath", as the code below shows.

However instead of the numeric id's which igraph has assigned to the
vertices (vertex1 & vertex2 in the example below) I would like to have
the vertex names that are there in the graph object y.


#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")

Cheers,
Joe.



reply via email to

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