Skip to contents

Each 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.

Usage

from_data_frame(...)

from_edgelist(...)

degseq(..., deterministic = FALSE)

tree(...)

Arguments

...

Forwarded to the corresponding constructor function.

deterministic

For degseq(), whether the construction should be deterministic; if TRUE, wraps realize_degseq() instead of sample_degseq().

Value

An object of class igraph_constructor_spec.

See also

graph_(), make_() and sample_() to apply a constructor specification.

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