Sunday, November 14, 2010

R: graphs, part2

load data from data frame:

col1 col2 weight
ничего космос 1.0
first two columns consider to be vertex names, third - weight
data<-read.table("/home/bliss/Study/Bauman/Magistr&Disser/Data/dat.txt",header=T,sep="\t")
gr<-graph.data.frame(as.data.frame(data),directed=T)


get vertex id by value: which(V(gr)$name=="космос")
get edge weight using vertex names: E(gr, P=c(which(V(gr)$name=="голубой")-1,which(V(gr)$name=="платок")-1))$weight
Vertex idx starts from 0, not 1!

No comments:

Post a Comment