Learn R Programming

dils (version 0.8.1)

EdgelistFromAdjacency: Convert an adjacency matrix to filled edgelist.

Description

Given the adjacency matrix for a network return a data.frame listing all possible edges and the weights for each edge.

Usage

EdgelistFromAdjacency(A, nodelist = paste("node", 1:nrow(A), sep = ""))

Arguments

A
matrix, see 'Details' for formatting assumptions.
nodelist
character, optional list of node names.

Value

data.frame, full list of all possible edges with weights for each in third column.

Details

This assumes that the row of the adjacency matrix indicates the node the edge is coming 'from', the column represent the node the edge is going 'to', and the value in the adjacency matrix is the weight given to the edge.

References

https://github.com/shaptonstahl/

See Also

EdgelistFromIgraph

Examples

Run this code
n <- 10
A <- matrix(rnorm(n*n), nrow=n)
A
EdgelistFromAdjacency(A)

n <- 100
A <- matrix(rnorm(n*n), nrow=n)
A
EdgelistFromAdjacency(A)

n <- 500
A <- matrix(rnorm(n*n), nrow=n)
A
## Not run: EdgelistFromAdjacency(A)

Run the code above in your browser using DataLab