Skip to contents

Adds or updates vertex and edge attributes in an igraph object using user-provided metadata tables. Vertex attributes are matched by the first column of nodes_table, and edge attributes are matched using the first two columns of edge_table, taking graph direction into account. Only matching nodes and edges are updated. Warnings are issued when there are unmatched entries.

Usage

assign_attributes(
  graph,
  nodes_table = NULL,
  edge_table = NULL,
  overwrite = TRUE
)

Arguments

graph

An igraph object or a data frame containing a symbolic edge list.

nodes_table

Optional. A data.frame whose first column corresponds to vertex names.

edge_table

Optional. A data.frame whose first two columns correspond to source and target vertices.

overwrite

Logical. If TRUE, existing attributes are overwritten. If FALSE, existing attributes are preserved. Default is TRUE.

Value

An igraph object with added or updated attributes.