Skip to content
Prev 298716 / 398498 Next

graph from txt file

Hello,

Package igraph can create graphs. Example:

dat <- read.table(text="
node1  node2  attr1  attr2
2  1  2  3
3  2  3  2
4  3  4  2
6  5  1  4
", header=TRUE)
dat

vertices <- as.vector( t(dat[, 1:2]) )

g <- graph(vertices, directed=FALSE)
E(g)$weight <- dat$attr1
E(g)$color <- dat$attr2

plot(g, layout=layout.circle, edge.label=E(g)$weight, edge.color=E(g)$color)


Also, you should post data examples like the posting guide says.
With your description, a small example like the one above would do.

Hope this helps,

Rui Barradas

Em 29-06-2012 19:05, HIMANSHU MITTAL escreveu: