edgelist_to_matrix: Transform an edgelist to a matrix

View source: R/utilities.R

edgelist_to_matrixR Documentation

Transform an edgelist to a matrix

Description

Transform an edgelist to a matrix

Usage

edgelist_to_matrix(
  E,
  digraph = TRUE,
  label = NULL,
  label2 = NULL,
  bipartite = FALSE
)

Arguments

E

An edge list

digraph

Whether the matrix is directed or not

label

A vector with the names of the nodes

label2

A vector with the names of a different set of nodes

bipartite

Whether the matrix is bipartite

Value

This function transform the edgelist into a matrix

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)
E <- matrix_to_edgelist(A)
edgelist_to_matrix(E, label = c("i"), digraph = FALSE)

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