1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/trigger_graph_actions.R
3\name{trigger_graph_actions}
4\alias{trigger_graph_actions}
5\title{Trigger the execution of a series of graph actions}
6\usage{
7trigger_graph_actions(graph)
8}
9\arguments{
10\item{graph}{A graph object of class \code{dgr_graph}.}
11}
12\value{
13A graph object of class \code{dgr_graph}.
14}
15\description{
16Execute the graph actions stored in the graph through the use of the
17\code{\link[=add_graph_action]{add_graph_action()}} function. These actions will be invoked in order and any
18errors encountered will trigger a warning message and result in no change to
19the input graph. Normally, graph actions are automatically triggered at every
20transformation step but this function allows for the manual triggering of
21graph actions after setting them, for example.
22}
23\examples{
24# Create a random graph using the
25# `add_gnm_graph()` function
26graph <-
27  create_graph() \%>\%
28  add_gnm_graph(
29    n = 5,
30    m = 10,
31    set_seed = 23)
32
33# Add a graph action that sets a node
34# attr column with a function; this
35# uses the `get_pagerank()` function
36# to provide PageRank values in the
37# `pagerank` column
38graph <-
39  graph \%>\%
40  add_graph_action(
41    fcn = "set_node_attr_w_fcn",
42    node_attr_fcn = "get_pagerank",
43    column_name = "pagerank",
44    action_name = "get_pagerank")
45
46# Add a second graph action (to be
47# executed after the first one) that
48# rescales values in the `pagerank`
49# column between 0 and 1, and, puts
50# these values in the `width` column
51graph <-
52  graph \%>\%
53  add_graph_action(
54    fcn = "rescale_node_attrs",
55    node_attr_from = "pagerank",
56    node_attr_to = "width",
57    action_name = "pgrnk_to_width")
58
59# Add a third and final graph action
60# (to be executed last) that creates
61# color values in the `fillcolor` column,
62# based on the numeric values from the
63# `width` column
64graph <-
65  graph \%>\%
66  add_graph_action(
67    fcn = "colorize_node_attrs",
68    node_attr_from = "width",
69    node_attr_to = "fillcolor",
70    action_name = "pgrnk_fillcolor")
71
72# View the graph actions for the graph
73# object by using the `get_graph_actions()`
74# function
75graph \%>\% get_graph_actions()
76
77# Manually trigger to invocation of
78# the graph actions using the
79# `trigger_graph_actions()` function
80graph <-
81  graph \%>\%
82  trigger_graph_actions()
83
84# Examine the graph's internal node
85# data frame (ndf) to verify that
86# the `pagerank`, `width`, and
87# `fillcolor` columns are present
88graph \%>\% get_node_df()
89
90}
91