Learn R Programming

cograph (version 2.7.2)

add_edges: Add Edges to a Network

Description

Add Edges to a Network

Usage

add_edges(x, from, to, weight = 1, ..., keep_format = FALSE, directed = NULL)

Value

A cograph_network with the new edges, or the input format when keep_format = TRUE. An edge that already exists has its weight replaced, and a cograph_edges_replaced warning says how many.

Arguments

x

Network input.

from

Source nodes, by label or index.

to

Target nodes, by label or index. The same length as from.

weight

Numeric weight for the new edges, length 1 or length(from). Default 1.

...

Named vectors of extra edge attributes, length 1 or length(from).

keep_format

Logical. Return the input format when TRUE.

directed

Logical or NULL. If NULL (default), auto-detect.

See Also

remove_edges, add_nodes, bind_networks

Examples

Run this code
adj <- matrix(0, 3, 3, dimnames = list(LETTERS[1:3], LETTERS[1:3]))
adj["A", "B"] <- adj["B", "A"] <- 1

add_edges(adj, from = "B", to = "C", weight = 0.5)

Run the code above in your browser using DataLab