Given this 5x5 adjacency matrix:
library(matrixcalc) set.seed(1) matrix(runif(25, 0, 10), nrow=5, ncol=5) %>% upper.triangle
Resulting in