Anna Yashina
Anna Yashina

Reputation: 534

Adjacency matrix from edge list in R

I have an unweighted edge list which I need to convert to a symmetric matrix for futher analysis. I use igraph function graph.data.frame() to create a graph object. Unfortunatelly I can't find a way to convert dgCMatrix to a matrix or creat a matrix right from the edge list. I'm sure there should be a simple way to do it.

Upvotes: 0

Views: 3787

Answers (1)

G5W
G5W

Reputation: 37641

If your graph.data.frame is GDF then you can get a sparse data matrix from

as_adjacency_matrix(GDF)

This is the dgCMatrix that you mention. But now you can just use

as.matrix(as_adjacency_matrix(GDF))

if you want the full matrix.

Upvotes: 2

Related Questions