Skip to contents

A ring is a one-dimensional lattice and this function is a special case of make_lattice().

Usage

make_ring(n, directed = FALSE, mutual = FALSE, circular = TRUE)

ring(n, directed = FALSE, mutual = FALSE, circular = TRUE)

Arguments

n

Number of vertices.

directed

Whether the graph is directed.

mutual

Whether directed edges are mutual. It is ignored in undirected graphs.

circular

Whether to create a circular ring. A non-circular ring is essentially a “line”: a tree where every non-leaf vertex has one child.

Value

An igraph graph.

ring()

Examples

print_all(make_ring(10))
#> ── <igraph> Ring graph ────────────────────────────────────────────── 3fd87ec ──
#>  undirected
#>  10 vertices · 10 edges
#> 
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph:  name <chr>, mutual <lgl>, circular <lgl>
#> 
#> ── Graph attributes ────────────────────────────────────────────────────────────
#> name:
#>   [1] "Ring graph"
#> mutual:
#>   [1] FALSE
#> circular:
#>   [1] TRUE
#> 
#> ── Edges ───────────────────────────────────────────────────────────────────────
#>  [1] 1 ─ 2   2 ─ 3   3 ─ 4   4 ─ 5   5 ─ 6   6 ─ 7   7 ─ 8   8 ─ 9   9 ─ 10 
#> [10] 1 ─ 10 
print_all(make_ring(10, directed = TRUE, mutual = TRUE))
#> ── <igraph> Ring graph ────────────────────────────────────────────── ec9f427 ──
#>  directed
#>  10 vertices · 20 edges
#> 
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph:  name <chr>, mutual <lgl>, circular <lgl>
#> 
#> ── Graph attributes ────────────────────────────────────────────────────────────
#> name:
#>   [1] "Ring graph"
#> mutual:
#>   [1] TRUE
#> circular:
#>   [1] TRUE
#> 
#> ── Edges ───────────────────────────────────────────────────────────────────────
#>  [1] 1 → 2   2 → 1   2 → 3   3 → 2   3 → 4   4 → 3   4 → 5   5 → 4   5 → 6  
#> [10] 6 → 5   6 → 7   7 → 6   7 → 8   8 → 7   8 → 9   9 → 8   9 → 10  10 → 9 
#> [19] 10 → 1  1 → 10