mat <- rbind(c(0, 0, 1, 1),
c(0, 0, 1, 1),
c(1, 1, 0, 1),
c(1, 1, 1, 0))
rownames(mat) <- colnames(mat) <- letters[1:4]
g1 <- graphAM(adjMat=mat)
stopifnot(identical(mat, as(g1, "matrix")), validObject(g1))
## now with weights:
mat[1,3] <- mat[3,1] <- 10
gw <- graphAM(adjMat=mat, values=list(weight=1))
## consistency check:
stopifnot(identical(mat, as(gw, "matrix")),
validObject(gw),
identical(gw, as(as(gw, "graphNEL"), "graphAM")))
Run the code above in your browser using DataLab