adjacency.to.edgelist: Convert adjacency matrix to edge list

Description Usage Arguments Value Examples

View source: R/adjacency.to.edgelist.R

Description

This function converts a weighted or unweighted adjacency matrix to an edge list.

Usage

1
adjacency.to.edgelist(adjacency, directed = NULL, weighted = NULL)

Arguments

adjacency

The input adjacency matrix.

directed

Logical scalar indicating whether the network is directed or undirected. Default is NULL, which means that the function checks whether the adjacency matrix is directed or not.

weighted

Logical scalar indicating whether the network is weighted or unweighted. Default is NULL, which means that the function checks whether the adjacency matrix is unweighted or not.

Value

Returns a matrix with two or three columns. The first column contains the ids of source nodes in the specified network, and the second column contains the ids of target nodes. The third column, specific for a weighted network, contains the weights of edges.

Examples

1
2
adj <- matrix(sample(c(0:4), 25, replace=TRUE), nr=5)
adjacency.to.edgelist(adj)

hangxiong/wNetwork documentation built on May 17, 2019, 2:28 p.m.