igraph-vs-attributes

0th

Percentile

Query or set attributes of the vertices in a vertex sequence

The $ operator is a syntactic sugar to query and set the attributes of the vertices in a vertex sequence.

Usage
# S3 method for igraph.vs
[[(x, i) <- value

# S3 method for igraph.vs [(x, i) <- value

# S3 method for igraph.vs $(x, name)

# S3 method for igraph.vs $(x, name) <- value

V(x) <- value

Arguments
x

A vertex sequence. For V<- it is a graph.

i

Index.

value

New value of the attribute, for the vertices in the vertex sequence.

name

Name of the vertex attribute to query or set.

Details

The query form of $ is a shortcut for vertex_attr, e.g. V(g)[idx]$attr is equivalent to vertex_attr(g, attr, V(g)[idx]).

The assignment form of $ is a shortcut for set_vertex_attr, e.g. V(g)[idx]$attr <- value is equivalent to g <- set_vertex_attr(g, attr, V(g)[idx], value).

Value

A vector or list, containing the values of attribute name for the vertices in the vertex sequence. For numeric, character or logical attributes, it is a vector of the appropriate type, otherwise it is a list.

See Also

Other graph attributes: $.igraph, $<-.igraph, igraph-dollar, igraph-dollar; attributes, graph_attr_names, list.graph.attributes; delete_edge_attr, remove.edge.attribute; delete_graph_attr, remove.graph.attribute; delete_vertex_attr, remove.vertex.attribute; edge.attributes<-, edge_attr<-; edge.attributes, edge_attr, get.edge.attribute; edge_attr_names, list.edge.attributes; get.graph.attribute, graph.attributes, graph_attr; get.vertex.attribute, vertex.attributes, vertex_attr; graph.attributes<-, graph_attr<-; list.vertex.attributes, vertex_attr_names; set.edge.attribute, set_edge_attr; set.graph.attribute, set_graph_attr; set.vertex.attribute, set_vertex_attr; vertex.attributes<-, vertex_attr<-

Other vertex and edge sequences: $.igraph.es, $<-.igraph.es, E<-, [<-.igraph.es, [[<-.igraph.es, igraph-es-attributes, igraph-es-attributes, igraph-es-attributes, igraph-es-attributes, igraph-es-attributes; E; V; [.igraph.es, %--%, %->%, %<-%, igraph-es-indexing; [.igraph.vs, igraph-vs-indexing; [[.igraph.es, igraph-es-indexing2; [[.igraph.vs, igraph-vs-indexing2; print.igraph.es; print.igraph.vs

Aliases
  • $.igraph.vs
  • $<-.igraph.vs
  • V<-
  • [<-.igraph.vs
  • [[<-.igraph.vs
  • igraph-vs-attributes
Examples
# NOT RUN {
g <- make_(ring(10),
  with_vertex_(
    name = LETTERS[1:10],
    color = sample(1:2, 10, replace=TRUE)
  )
)
V(g)$name
V(g)$color
V(g)$frame.color <- V(g)$color

# color vertices of the largest component
largest_comp <- function(graph) {
  cl <- components(graph)
  V(graph)[which.max(cl$csize) == cl$membership]
}
g <- sample_(gnp(100, 2/100),
  with_vertex_(size = 3, label = ""),
  with_graph_(layout = layout_with_fr)
)
giant_v <- largest_comp(g)
V(g)$color <- "blue"
V(g)[giant_v]$color <- "orange"
plot(g)
# }
Documentation reproduced from package igraph, version 1.0.1, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.