0

I have already derived vertex connections of the graph. It is a matrix with 3 columns. Column 1 contains vertex i, column 2 contains all its adjacent vertexes, column 3 contains the edge weight, so the data are already processed into something like {{1,1,0.8} {1, 3, 0.4}, {2, 3, 0.5} ...}.

Yet I do not know how to incorporate this into igraph in R. Seems to me all presented igraph work are initiated from matrix containing original raw data.

TylerH
  • 20,799
  • 66
  • 75
  • 101
user3381299
  • 177
  • 1
  • 7

1 Answers1

2

Read in ?"igraph-package" under the section Creating graphs, and you will find the relevant information. In your case, using graph.data.frame is sufficient.

d <- data.frame(from=c(1, 1, 2), to=c(1, 3, 3), weight=c(0.8, 0.4, 0.5))
graph.data.frame(d)
Gabor Csardi
  • 10,705
  • 1
  • 36
  • 53
nograpes
  • 18,623
  • 1
  • 44
  • 67