-
Notifications
You must be signed in to change notification settings - Fork 4
/
12-fcns_traversals.Rmd
176 lines (87 loc) · 9.17 KB
/
12-fcns_traversals.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# Functions: Traversals {#fcns_traversals}
## `trav_out()`
<img src="diagrams/traversals/trav_out.svg">
<h4><em>Traverse from one or more selected nodes onto adjacent, outward nodes</em></h4>
<h5>DESCRIPTION</h5>
From a graph object of class `dgr_graph` move along outward edges from one or more nodes present in a selection to other connected nodes, replacing the current nodes in the selection with those nodes traversed to. An optional filter by node attribute can limit the set of nodes traversed to.
<h5>PARAMETERS</h5>
**`graph`** a graph object of class `dgr_graph`.
**`conditions`** an option to use filtering conditions for the traversal.
**`copy_attrs_from`** providing a node attribute name will copy those node attribute values to the traversed nodes. Any values extant on the nodes traversed to will be replaced.
**`agg`** if a node attribute is provided to `copy_attrs_from`, then an aggregation function is required since there may be cases where multiple edge attribute values will be passed onto the traversed node(s). To pass only a single value, the following aggregation functions can be used: `sum`, `min`, `max`, `mean`, or `median`.
## `trav_in()`
<img src="diagrams/traversals/trav_in.svg">
<h4><em>Traverse from one or more selected nodes onto adjacent, inward nodes</em></h4>
<h5>DESCRIPTION</h5>
From a graph object of class `dgr_graph` move along inward edges from one or more nodes present in a selection to other connected nodes, replacing the current nodes in the selection with those nodes traversed to. An optional filter by node attribute can limit the set of nodes traversed to.
<h5>PARAMETERS</h5>
**`graph`** a graph object of class `dgr_graph`.
**`conditions`** an option to use filtering conditions for the traversal.
**`copy_attrs_from`** providing a node attribute name will copy those node attribute values to the traversed nodes. Any values extant on the nodes traversed to will be replaced.
**`agg`** if a node attribute is provided to `copy_attrs_from`, then an aggregation function is required since there may be cases where multiple edge attribute values will be passed onto the traversed node(s). To pass only a single value, the following aggregation functions can be used: `sum`, `min`, `max`, `mean`, or `median`.
## `trav_both()`
<img src="diagrams/traversals/trav_both.svg">
<h4><em>Traverse from one or more selected nodes onto neighboring nodes</em></h4>
<h5>DESCRIPTION</h5>
From a graph object of class `dgr_graph` move from one or more nodes present in a selection to other nodes that are connected by edges, replacing the current nodes in the selection with those nodes traversed to. An optional filter by node attribute can limit the set of nodes traversed to.
<h5>PARAMETERS</h5>
**`graph`** a graph object of class `dgr_graph`.
**`conditions`** an option to use filtering conditions for the traversal.
**`copy_attrs_from`** providing a node attribute name will copy those node attribute values to the traversed nodes. Any values extant on the nodes traversed to will be replaced.
**`agg`** if a node attribute is provided to `copy_attrs_from`, then an aggregation function is required since there may be cases where multiple edge attribute values will be passed onto the traversed node(s). To pass only a single value, the following aggregation functions can be used: `sum`, `min`, `max`, `mean`, or `median`.
## `trav_out_edge()`
<img src="diagrams/traversals/trav_out_edge.svg">
<h4><em>Traverse from one or more selected nodes onto adjacent, outward edges</em></h4>
<h5>DESCRIPTION</h5>
From a graph object of class `dgr_graph` move to outgoing edges from a selection of one or more selected nodes, thereby creating a selection of edges. An optional filter by edge attribute can limit the set of edges traversed to.
<h5>PARAMETERS</h5>
**`graph`** a graph object of class `dgr_graph`.
**`conditions`** an option to use filtering conditions for the traversal.
**`copy_attrs_from`** providing a node attribute name will copy those node attribute values to the traversed edges. If the edge attribute already exists, the values will be merged to the traversed edges; otherwise, a new edge attribute will be created.
## `trav_in_edge()`
<img src="diagrams/traversals/trav_in_edge.svg">
<h4><em>Traverse from one or more selected nodes onto adjacent, inward edges</em></h4>
<h5>DESCRIPTION</h5>
From a graph object of class `dgr_graph` move to incoming edges from a selection of one or more selected nodes, thereby creating a selection of edges. An optional filter by edge attribute can limit the set of edges traversed to.
<h5>PARAMETERS</h5>
**`graph`** a graph object of class `dgr_graph`.
**`conditions`** an option to use filtering conditions for the traversal.
**`copy_attrs_from`** providing a node attribute name will copy those node attribute values to the traversed edges. If the edge attribute already exists, the values will be merged to the traversed edges; otherwise, a new edge attribute will be created.
## `trav_both_edge()`
<img src="diagrams/traversals/trav_both_edge.svg">
<h4><em>Traverse from one or more selected nodes onto adjacent edges</em></h4>
<h5>DESCRIPTION</h5>
From a graph object of class `dgr_graph` move to adjacent edges from a selection of one or more selected nodes, thereby creating a selection of edges. An optional filter by edge attribute can limit the set of edges traversed to.
<h5>PARAMETERS</h5>
**`graph`** a graph object of class `dgr_graph`.
**`conditions`** an option to use filtering conditions for the traversal.
**`copy_attrs_from`** providing a node attribute name will copy those node attribute values to the traversed edges. If the edge attribute already exists, the values will be merged to the traversed edges; otherwise, a new edge attribute will be created.
**`agg`** if a node attribute is provided to `copy_attrs_from`, then an aggregation function is required since there may be cases where multiple node attribute values will be passed onto the traversed edge(s). To pass only a single value, the following aggregation functions can be used: `sum`, `min`, `max`, `mean`, or `median`.
## `trav_out_node()`
<img src="diagrams/traversals/trav_out_node.svg">
<h4><em>Traverse from one or more selected edges onto adjacent, outward nodes</em></h4>
<h5>DESCRIPTION</h5>
From a graph object of class `dgr_graph` with an active selection of edges move opposite to the edge direction to connected nodes, replacing the current edge selection with those nodes traversed to. An optional filter by node attribute can limit the set of nodes traversed to.
<h5>PARAMETERS</h5>
**`graph`** a graph object of class `dgr_graph`.
**`conditions`** an option to use filtering conditions for the traversal.
**`copy_attrs_from`** providing an edge attribute name will copy those edge attribute values to the traversed nodes. If the edge attribute already exists, the values will be merged to the traversed nodes; otherwise, a new node attribute will be created.
**`agg`** if an edge attribute is provided to `copy_attrs_from`, then an aggregation function is required since there may be cases where multiple edge attribute values will be passed onto the traversed node(s). To pass only a single value, the following aggregation functions can be used: `sum`, `min`, `max`, `mean`, or `median`.
## `trav_in_node()`
<img src="diagrams/traversals/trav_in_node.svg">
<h4><em>Traverse from one or more selected edges onto adjacent, inward nodes</em></h4>
<h5>DESCRIPTION</h5>
From a graph object of class `dgr_graph` with an active selection of edges move with the edge direction to connected nodes, replacing the current edges in the selection with those nodes traversed to. An optional filter by node attribute can limit the set of nodes traversed to.
<h5>PARAMETERS</h5>
**`graph`** a graph object of class `dgr_graph`.
**`conditions`** an option to use filtering conditions for the traversal.
**`copy_attrs_from`** providing an edge attribute name will copy those edge attribute values to the traversed nodes. If the edge attribute already exists, the values will be merged to the traversed nodes; otherwise, a new node attribute will be created.
**`agg`** if an edge attribute is provided to `copy_attrs_from`, then an aggregation function is required since there may be cases where multiple edge attribute values will be passed onto the traversed node(s). To pass only a single value, the following aggregation functions can be used: `sum`, `min`, `max`, `mean`, or `median`.
## `trav_reverse_edge()`
<img src="diagrams/traversals/trav_reverse_edge.svg">
<h4><em>Select any reverse edges from a selection of edges</em></h4>
<h5>DESCRIPTION</h5>
From an active selection of edges in a graph object of class `dgr_graph`, select any of the available reverse edges between the nodes common to the selected edges. For instance, if an active selection has the edge `1->2` but there is also an (unselected) edge `2->1`, then this function can either switch to the selection of `2->1`, or, incorporate those edges in the active selection of edges.
<h5>PARAMETERS</h5>
**`graph`** a graph object of class `dgr_graph`.
**`add_to_selection`** an option to either add the reverse edges to the active selection of edges or switch the active selection entirely to those reverse edges (`FALSE`, the default case).