Skip to contents

Set edge attributes

Usage

set_edge_attr(graph, name, edges = NULL, value, index = deprecated())

Arguments

graph

The graph

name

The name of the attribute to set.

edges

An optional edge sequence to set the attributes of a subset of edges. The default NULL selects all edges.

value

The new value of the attribute for all (or edges) edges. If NULL, the input is returned unchanged.

index

[Deprecated] Use edges instead.

Value

The graph, with the edge attribute added or set.

edges(), get_eids(), vcount(), ecount()

Examples

g <- make_ring(10) %>%
  set_edge_attr("label", value = LETTERS[1:10])
g
#> ── <igraph> Ring graph ────────────────────────────────────────────── 9c30c61 ──
#> ℹ undirected
#> ℹ 10 vertices · 10 edges
#> 
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph:  name <chr>, mutual <lgl>, circular <lgl>
#> → edge:   label <chr>
#> 
#> ── Edges ───────────────────────────────────────────────────────────────────────
#>  [1] 1 ─ 2   2 ─ 3   3 ─ 4   4 ─ 5   5 ─ 6   6 ─ 7   7 ─ 8   8 ─ 9   9 ─ 10 
#> [10] 1 ─ 10 
plot(g)