These functions allow you to map over the nodes in a graph, by first
performing a breath first search on the graph and then mapping over each
node in the order they are visited. The mapping function will have access to
the result and search statistics for all the nodes between itself and the
root in the search. To map over the nodes in the reverse direction use
1 2 3 4 5 6 7 8 9
map_bfs(root, mode = "out", unreachable = FALSE, .f, ...) map_bfs_lgl(root, mode = "out", unreachable = FALSE, .f, ...) map_bfs_chr(root, mode = "out", unreachable = FALSE, .f, ...) map_bfs_int(root, mode = "out", unreachable = FALSE, .f, ...) map_bfs_dbl(root, mode = "out", unreachable = FALSE, .f, ...)
The node to start the search from
How should edges be followed?
Should the search jump to an unvisited node if the search is completed without visiting all nodes.
A function to map over all nodes. See Details
Additional parameters to pass to
The function provided to
.f will be called with the following arguments in
addition to those supplied through
graph: The full
node: The index of the node currently mapped over
rank: The rank of the node in the search
parent: The index of the node that led to the current node
before: The index of the node that was visited before the current node
after: The index of the node that was visited after the current node.
dist: The distance of the current node from the root
path: A table containing
result columns giving the values for each node leading to the
current node. The
result column will contain the result of the mapping
of each node in a list.
Instead of spelling out all of these in the function it is possible to simply
name the ones needed and use
... to catch the rest.
map_bfs() returns a list of the same length as the number of nodes
in the graph, in the order matching the node order in the graph (that is, not
in the order they are called).
map_bfs_*() tries to coerce its result into
a vector of the classes
These functions will throw an error if they are unsuccesful, so they are type
1 2 3 4 5 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.