| as_adjacency_matrix | R Documentation |
Sometimes it is useful to work with a standard representation of a graph, like an adjacency matrix.
as_adjacency_matrix(
graph,
type = c("both", "upper", "lower"),
attr = NULL,
edges = deprecated(),
names = TRUE,
sparse = igraph_opt("sparsematrices")
)
as_adjacency_matrix() returns the adjacency matrix of a graph, a
regular matrix if sparse is FALSE, or a sparse matrix, as
defined in the ‘Matrix’ package, if sparse if
TRUE.
A vcount(graph) by vcount(graph) (usually) numeric
matrix.
graph_from_adjacency_matrix(), read_graph()
Other conversion:
as.matrix.igraph(),
as_adj_list(),
as_biadjacency_matrix(),
as_data_frame(),
as_directed(),
as_edgelist(),
as_graphnel(),
as_long_data_frame(),
graph_from_adj_list(),
graph_from_graphnel()
g <- sample_gnp(10, 2 / 10)
as_adjacency_matrix(g)
V(g)$name <- letters[1:vcount(g)]
as_adjacency_matrix(g)
E(g)$weight <- runif(ecount(g))
as_adjacency_matrix(g, attr = "weight")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.