Description Usage Arguments Details Value See Also Examples

Sometimes it is useful to work with a standard representation of a graph, like an adjacency matrix.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |

`graph` |
The graph to convert. |

`type` |
Gives how to create the adjacency matrix for undirected graphs.
It is ignored for directed graphs. Possible values: |

`attr` |
Either Note that this works only for certain attribute types. If the |

`edges` |
Logical scalar, whether to return the edge ids in the matrix. For non-existant edges zero is returned. |

`names` |
Logical constant, whether to assign row and column names
to the matrix. These are only assigned if the |

`sparse` |
Logical scalar, whether to create a sparse matrix. The
‘ |

`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`

1 2 3 4 5 6 | ```
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")
``` |

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.