Skip to contents

Set all or some graph attributes

Usage

graph_attr(graph, name) <- value

Arguments

graph

The graph.

name

The name of the attribute to set. If missing, then value should be a named list, and all list members are set as attributes.

value

The value of the attribute to set

Value

The graph, with the attribute(s) added.

Examples

g <- make_graph(~ A - B:C:D)
graph_attr(g, "name") <- "4-star"
g
#> ── <igraph> 4-star ────────────────────────────────────────────────── 21e8965 ──
#>  undirected · named
#>  4 vertices · 3 edges
#> 
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph:  name <chr>
#> → vertex: name <chr>
#> 
#> ── Edges (vertex names) ────────────────────────────────────────────────────────
#> [1] A ─ B  A ─ C  A ─ D 

graph_attr(g) <- list(
  layout = layout_with_fr(g),
  name = "4-star layed out"
)
plot(g)