library(igraph)
d <- data.frame(
from = rep(c(1, 2, 3), 3), to = rep(c(2, 3, 1), 3),
type = rep(c("a", "b", "c"), each = 3), weight = 1:9
)
graph_from_multi_edgelist(d, "from", "to", "type", "weight")
Run the code above in your browser using DataLab