as.matrix.igraph | R Documentation |

Get adjacency or edgelist representation of the network stored as an
`igraph`

object.

```
## S3 method for class 'igraph'
as.matrix(x, matrix.type = c("adjacency", "edgelist"), ...)
```

`x` |
object of class igraph, the network |

`matrix.type` |
character, type of matrix to return, currently "adjacency" or "edgelist" are supported |

`...` |
other arguments to/from other methods |

If `matrix.type`

is `"edgelist"`

, then a two-column numeric edge list
matrix is returned. The value of `attrname`

is ignored.

If `matrix.type`

is `"adjacency"`

, then a square adjacency matrix is
returned. For adjacency matrices, you can use the `attr`

keyword argument
to use the values of an edge attribute in the matrix cells. See the
documentation of as_adjacency_matrix for more details.

Other arguments passed through `...`

are passed to either
`as_adjacency_matrix()`

or `as_edgelist()`

depending on the value of `matrix.type`

.

Depending on the value of `matrix.type`

either a square
adjacency matrix or a two-column numeric matrix representing the edgelist.

Michal Bojanowski, originally from the `intergraph`

package

`as_adjacency_matrix()`

, `as_edgelist()`

Other conversion:
`as.directed()`

,
`as_adj_list()`

,
`as_adjacency_matrix()`

,
`as_data_frame()`

,
`as_edgelist()`

,
`as_graphnel()`

,
`as_incidence_matrix()`

,
`as_long_data_frame()`

,
`graph_from_adj_list()`

,
`graph_from_graphnel()`

```
g <- make_graph("zachary")
as.matrix(g, "adjacency")
as.matrix(g, "edgelist")
# use edge attribute "weight"
E(g)$weight <- rep(1:10, length.out = ecount(g))
as.matrix(g, "adjacency", sparse = FALSE, attr = "weight")
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.