Skip to contents

A subset of edges can be assign a different thickness or color.

Usage

set_attributes_to_edges_visnetwork(
  edges,
  subset_edges,
  width = c(NA, NA),
  color = c(NULL, NULL)
)

Arguments

edges

A data.frame create by create_edges_visnetwork

subset_edges

A list with the elements from and to. Both from and to are vectors of the same length denoting the different edges

width

Vector with two values. The first is assigned to the edges in the subset given by subset_edges. The second value is assigned to the rest. If width = c(NA,NA), no width is assigned

color

Vector with two values. The first is assigned to the edges in the subset given by subset_edges. The second value is assigned to the rest. If color = c(NULL,NULL), no color is assigned

Value

A data frame that can be used by the visNetwork package

Examples

nodes <- create_nodes_visnetwork(n_nodes = 5, labels = LETTERS[1:5])

adj_matrix <- matrix(c(0, 1, 0, 1, 0,
                       1, 0, 1, 0, 0,
                       0, 1, 0, 0, 0,
                       1, 0, 0, 0, 1,
                       0, 0, 0, 1, 0), ncol = 5)

edges <- create_edges_visnetwork(adj_matrix)

shared_edges <- data.frame(from = c(1,2), to = c(4, 3))

edges <- set_attributes_to_edges_visnetwork(edges,
                                            subset_edges = shared_edges,
                                            width = c(3, .5),
                                            color = c("red", "blue"))

visnetwork(nodes, edges)