list_to_matrix: Edge list to matrix conversion

View source: R/list_to_matrix.R

list_to_matrixR Documentation

Edge list to matrix conversion

Description

Convert an edge list to a matrix. Can handle unipartite and bipartite networks.

Usage

list_to_matrix(
  x,
  directed = FALSE,
  bipartite = TRUE,
  group_names = c("set_cols", "set_rows"),
  node_metadata = NULL
)

Arguments

x

An edge list of the format from to weight.

directed

Is the network directed?

bipartite

Is network bipartite?

group_names

For bipartite networks: name of the groups in the columns and rows, respectively (e.g., parasites and hosts).

node_metadata

Following the igraph method of graph_from_data_frame. Must have a column called node_name with names matching those in x.

Details

It is also possible to add node attributes. For this, it uses igraph. The first column in the node_metadata data frame should have the names of the nodes in the edge list.

Value

A monolayer object.

See Also

Functions create_monolayer_network, monolayer and graph_from_data_frame from igraph.

Examples

library(dplyr)
network <- load_emln(17)
nodes <- network$nodes
links<-subset(network$extended_ids %>% filter(layer_from==1), select=c(node_from, node_to, weight))

list_to_matrix(links, directed = TRUE, bipartite = FALSE, node_metadata = nodes)


# See examples in:
# https://emln.ecomplab.com/monolayer.html#Unipartite


emln documentation built on May 6, 2026, 1:06 a.m.