
Constructor specifications for graph_(), make_() and sample_()
Source: R/conversion.R, R/games.R, R/make.R
constructor_spec.RdEach of these functions builds a lazy constructor specification for the
given graph constructor, to be used with graph_(), make_() or
sample_(). The specification is only evaluated when the graph is actually
constructed, so it can be combined with constructor modifiers such as
with_vertex_() or with_edge_().
from_data_frame(), from_edgelist(), tree() and degseq() wrap
graph_from_data_frame(), graph_from_edgelist(), make_tree() (or
sample_tree()) and sample_degseq() (or realize_degseq()),
respectively.
The other constructors have specification functions as well; they are
documented together with the constructor they wrap, e.g. ring() on the
make_ring() page.
Arguments
- ...
Forwarded to the corresponding constructor function.
- deterministic
For
degseq(), whether the construction should be deterministic; ifTRUE, wrapsrealize_degseq()instead ofsample_degseq().
Examples
# Pass a constructor specification to graph_(), make_() or sample_()
el <- cbind(1:5, c(2:5, 1))
graph_(el, from_edgelist(directed = FALSE))
#> Warning: `graph_()` was deprecated in igraph 2.1.0.
#> ℹ Please use constructors directly, for instance graph_from_edgelist().
#> ℹ graph_() will be removed in a future version of igraph.
#> ── <igraph> ───────────────────────────────────────────────────────── 9509628 ──
#> ℹ undirected
#> ℹ 5 vertices · 5 edges
#>
#> ── Edges ───────────────────────────────────────────────────────────────────────
#> [1] 1 ─ 2 2 ─ 3 3 ─ 4 4 ─ 5 1 ─ 5
make_(tree(7))
#> ── <igraph> Tree ──────────────────────────────────────────────────── 49d6e46 ──
#> ℹ directed
#> ℹ 7 vertices · 6 edges
#>
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph: name <chr>, children <dbl>, mode <chr>
#>
#> ── Edges ───────────────────────────────────────────────────────────────────────
#> [1] 1 → 2 1 → 3 2 → 4 2 → 5 3 → 6 3 → 7
# Specifications can be combined with constructor modifiers
make_(tree(7), with_vertex_(color = "red"))
#> ── <igraph> Tree ──────────────────────────────────────────────────── da5c77c ──
#> ℹ directed
#> ℹ 7 vertices · 6 edges
#>
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph: name <chr>, children <dbl>, mode <chr>
#> → vertex: color <chr>
#>
#> ── Edges ───────────────────────────────────────────────────────────────────────
#> [1] 1 → 2 1 → 3 2 → 4 2 → 5 3 → 6 3 → 7