EVOLUTION-MANAGER
Edit File: igraph-vs-attributes.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Query or set attributes of the vertices in a vertex sequence</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for igraph-vs-attributes {igraph}"><tr><td>igraph-vs-attributes {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Query or set attributes of the vertices in a vertex sequence</h2> <h3>Description</h3> <p>The <code>$</code> operator is a syntactic sugar to query and set the attributes of the vertices in a vertex sequence. </p> <h3>Usage</h3> <pre> ## S3 replacement method for class 'igraph.vs' x[[i]] <- value ## S3 replacement method for class 'igraph.vs' x[i] <- value ## S3 method for class 'igraph.vs' x$name ## S3 replacement method for class 'igraph.vs' x$name <- value V(x) <- value </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A vertex sequence. For <code>V<-</code> it is a graph.</p> </td></tr> <tr valign="top"><td><code>i</code></td> <td> <p>Index.</p> </td></tr> <tr valign="top"><td><code>value</code></td> <td> <p>New value of the attribute, for the vertices in the vertex sequence.</p> </td></tr> <tr valign="top"><td><code>name</code></td> <td> <p>Name of the vertex attribute to query or set.</p> </td></tr> </table> <h3>Details</h3> <p>The query form of <code>$</code> is a shortcut for <code><a href="vertex_attr.html">vertex_attr</a></code>, e.g. <code>V(g)[idx]$attr</code> is equivalent to <code>vertex_attr(g, attr, V(g)[idx])</code>. </p> <p>The assignment form of <code>$</code> is a shortcut for <code><a href="set_vertex_attr.html">set_vertex_attr</a></code>, e.g. <code>V(g)[idx]$attr <- value</code> is equivalent to <code>g <- set_vertex_attr(g, attr, V(g)[idx], value)</code>. </p> <h3>Value</h3> <p>A vector or list, containing the values of attribute <code>name</code> 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. </p> <h3>See Also</h3> <p>Other vertex and edge sequences: <code><a href="E.html">E</a>()</code>, <code><a href="V.html">V</a>()</code>, <code><a href="igraph-es-attributes.html">igraph-es-attributes</a></code>, <code><a href="igraph-es-indexing2.html">igraph-es-indexing2</a></code>, <code><a href="igraph-es-indexing.html">igraph-es-indexing</a></code>, <code><a href="igraph-vs-indexing2.html">igraph-vs-indexing2</a></code>, <code><a href="igraph-vs-indexing.html">igraph-vs-indexing</a></code>, <code><a href="print.igraph.es.html">print.igraph.es</a>()</code>, <code><a href="print.igraph.vs.html">print.igraph.vs</a>()</code> </p> <p>Other graph attributes: <code><a href="delete_edge_attr.html">delete_edge_attr</a>()</code>, <code><a href="delete_graph_attr.html">delete_graph_attr</a>()</code>, <code><a href="delete_vertex_attr.html">delete_vertex_attr</a>()</code>, <code><a href="edge_attr-set.html">edge_attr<-</a>()</code>, <code><a href="edge_attr_names.html">edge_attr_names</a>()</code>, <code><a href="edge_attr.html">edge_attr</a>()</code>, <code><a href="graph_attr-set.html">graph_attr<-</a>()</code>, <code><a href="graph_attr_names.html">graph_attr_names</a>()</code>, <code><a href="graph_attr.html">graph_attr</a>()</code>, <code><a href="igraph-dollar.html">igraph-dollar</a></code>, <code><a href="set_edge_attr.html">set_edge_attr</a>()</code>, <code><a href="set_graph_attr.html">set_graph_attr</a>()</code>, <code><a href="set_vertex_attr.html">set_vertex_attr</a>()</code>, <code><a href="vertex_attr-set.html">vertex_attr<-</a>()</code>, <code><a href="vertex_attr_names.html">vertex_attr_names</a>()</code>, <code><a href="vertex_attr.html">vertex_attr</a>()</code> </p> <h3>Examples</h3> <pre> 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) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>