returns the weighted adjacency matrix in dense format
Arguments
- g
An igraph object
- attr
Either NULL or a character string giving an edge attribute name. If NULL a traditional adjacency matrix is returned. If not NULL then the values of the given edge attribute are included in the adjacency matrix.
Details
This method is faster than as_adj from igraph if you need the weighted adjacency matrix in dense format
Examples
library(igraph)
g <- sample_gnp(10, 0.2)
E(g)$weight <- runif(ecount(g))
as_adj_weighted(g, attr="weight")
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> [1,] 0 0.0000000 0.00000000 0 0.0000000 0.0000000 0.000000 0.00000000
#> [2,] 0 0.0000000 0.00000000 0 0.0000000 0.3004258 0.000000 0.00000000
#> [3,] 0 0.0000000 0.00000000 0 0.0000000 0.0000000 0.000000 0.09654597
#> [4,] 0 0.0000000 0.00000000 0 0.0000000 0.0000000 0.000000 0.00000000
#> [5,] 0 0.0000000 0.00000000 0 0.0000000 0.0000000 0.000000 0.52269014
#> [6,] 0 0.3004258 0.00000000 0 0.0000000 0.0000000 0.000000 0.00000000
#> [7,] 0 0.0000000 0.00000000 0 0.0000000 0.0000000 0.000000 0.00000000
#> [8,] 0 0.0000000 0.09654597 0 0.5226901 0.0000000 0.000000 0.00000000
#> [9,] 0 0.5930332 0.00000000 0 0.0000000 0.0000000 0.000000 0.00000000
#> [10,] 0 0.6503604 0.00000000 0 0.0000000 0.0000000 0.369656 0.00000000
#> [,9] [,10]
#> [1,] 0.0000000 0.0000000
#> [2,] 0.5930332 0.6503604
#> [3,] 0.0000000 0.0000000
#> [4,] 0.0000000 0.0000000
#> [5,] 0.0000000 0.0000000
#> [6,] 0.0000000 0.0000000
#> [7,] 0.0000000 0.3696560
#> [8,] 0.0000000 0.0000000
#> [9,] 0.0000000 0.0000000
#> [10,] 0.0000000 0.0000000