Skip to contents

The double bracket operator can be used on vertex sequences, to print the meta-data (vertex attributes) of the vertices in the sequence.

Usage

# S3 method for igraph.vs
[[(x, ...)

Arguments

x

A vertex sequence.

...

Additional arguments, passed to [.

Value

The double bracket operator returns another vertex sequence, with meta-data (attribute) printing turned on. See details below.

Details

Technically, when used with vertex sequences, the double bracket operator does exactly the same as the single bracket operator, but the resulting vertex sequence is printed differently: all attributes of the vertices in the sequence are printed as well.

See [.igraph.vs for more about indexing vertex sequences.

Examples

g <- make_ring(10) %>%
  set_vertex_attr("color", value = "red") %>%
  set_vertex_attr("name", value = LETTERS[1:10])
V(g)
#> + 10/10 vertices, named, from 2f8dfbf:
#>  [1] A B C D E F G H I J
V(g)[[]]
#> + 10/10 vertices, named, from 2f8dfbf:
#>    color name
#> 1    red    A
#> 2    red    B
#> 3    red    C
#> 4    red    D
#> 5    red    E
#> 6    red    F
#> 7    red    G
#> 8    red    H
#> 9    red    I
#> 10   red    J
V(g)[1:5]
#> + 5/10 vertices, named, from 2f8dfbf:
#> [1] A B C D E
V(g)[[1:5]]
#> + 5/10 vertices, named, from 2f8dfbf:
#>   color name
#> 1   red    A
#> 2   red    B
#> 3   red    C
#> 4   red    D
#> 5   red    E