matrix_adjlist: Transform a matrix to an adjacency list

View source: R/utilities.R

matrix_adjlistR Documentation

Transform a matrix to an adjacency list

Description

Transform a matrix to an adjacency list

Usage

matrix_adjlist(A)

Arguments

A

A matrix

Value

This function transform a matrix to an adjacency list

Author(s)

Alejandro Espinosa-Rada

Examples

A <- matrix(c(
  0, 1, 1, 0, 0, 0, 0, 1, 0,
  1, 0, 1, 0, 0, 0, 0, 0, 0,
  1, 1, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 1, 1, 0, 0, 0,
  0, 0, 0, 1, 0, 0, 0, 0, 0,
  0, 0, 0, 1, 0, 0, 1, 1, 0,
  0, 0, 0, 0, 0, 1, 0, 1, 0,
  1, 0, 0, 0, 0, 1, 1, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0
), byrow = TRUE, ncol = 9)
rownames(A) <- letters[1:nrow(A)]
colnames(A) <- rownames(A)
matrix_adjlist(A)

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