matrix_to_edgelist: Transform a square matrix to an edge-list

View source: R/utilities.R

matrix_to_edgelistR Documentation

Transform a square matrix to an edge-list

Description

Transform a square matrix to an edge-list

Usage

matrix_to_edgelist(A, digraph = FALSE, valued = FALSE, loops = FALSE)

Arguments

A

A square matrix

digraph

Whether the matrix is directed or not

valued

Add a third columns with the valued of the relationship

loops

Whether the loops are retained or not

Value

This function transform the matrix into an edgelist

Author(s)

Alejandro Espinosa-Rada

Examples

A <- matrix(c(
  0, 2, 1,
  1, 0, 0,
  1, 0, 1
), byrow = TRUE, ncol = 3)
matrix_to_edgelist(A, digraph = TRUE, valued = TRUE, loops = TRUE)

anespinosa/netmem documentation built on April 5, 2025, 5:02 p.m.