1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/get_node_attrs_ws.R
3\name{get_node_attrs_ws}
4\alias{get_node_attrs_ws}
5\title{Get node attribute values from a selection of nodes}
6\usage{
7get_node_attrs_ws(graph, node_attr)
8}
9\arguments{
10\item{graph}{A graph object of class \code{dgr_graph}.}
11
12\item{node_attr}{The name of the attribute for which to get values.}
13}
14\value{
15A named vector of node attribute values for the attribute given by
16\code{node_attr} by node ID.
17}
18\description{
19From a graph object of class \code{dgr_graph}, get node attribute values from
20nodes currently active as a selection.
21}
22\details{
23This function makes use of an active selection of nodes (and the function
24ending with \verb{_ws} hints at this).
25
26Selections of nodes can be performed using the following node selection
27(\verb{select_*()}) functions: \code{\link[=select_nodes]{select_nodes()}}, \code{\link[=select_last_nodes_created]{select_last_nodes_created()}},
28\code{\link[=select_nodes_by_degree]{select_nodes_by_degree()}}, \code{\link[=select_nodes_by_id]{select_nodes_by_id()}}, or
29\code{\link[=select_nodes_in_neighborhood]{select_nodes_in_neighborhood()}}.
30
31Selections of nodes can also be performed using the following traversal
32(\verb{trav_*()}) functions: \code{\link[=trav_out]{trav_out()}}, \code{\link[=trav_in]{trav_in()}}, \code{\link[=trav_both]{trav_both()}},
33\code{\link[=trav_out_node]{trav_out_node()}}, \code{\link[=trav_in_node]{trav_in_node()}}, \code{\link[=trav_out_until]{trav_out_until()}}, or
34\code{\link[=trav_in_until]{trav_in_until()}}.
35}
36\examples{
37# Create a random graph using the
38# `add_gnm_graph()` function
39graph <-
40  create_graph() \%>\%
41  add_gnm_graph(
42    n = 4,
43    m = 4,
44    set_seed = 23) \%>\%
45  set_node_attrs(
46    node_attr = value,
47    values = c(2.5, 8.2, 4.2, 2.4))
48
49# Select nodes with ID values
50# `1` and `3`
51graph <-
52  graph \%>\%
53  select_nodes_by_id(
54    nodes = c(1, 3))
55
56# Get the node attribute values
57# for the `value` attribute, limited
58# to the current node selection
59graph \%>\%
60  get_node_attrs_ws(
61    node_attr = value)
62
63}
64