adj_to_matrix: Transform an adjacency list into a matrix

View source: R/utilities.R

adj_to_matrixR Documentation

Transform an adjacency list into a matrix

Description

Transform an adjacency list into a matrix

Usage

adj_to_matrix(A, type = c("adjacency", "incidence", "weighted"), loops = FALSE)

Arguments

A

An adjacent list

type

Transform the adjacent list into an adjacency matrix, an incidence matrix or a weighted matrix

loops

Whether to include loops into the matrix

Value

This function transforms an adjacency list into a matrix

Author(s)

Alejandro Espinosa-Rada

Examples

adj_groups <- rbind(
  c("a", "b", "c"), c("a", "c", NA),
  c("b", "c", NA), c("c", NA, NA),
  c("c", "a", NA)
)
M <- adj_to_matrix(adj_groups, type = "adjacency", loops = TRUE)
M

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