traverse: Traverse a graph.

Description Usage Arguments Value See Also Examples

Description

Traverse the whole graph or its subset. graph is a graph structure as returned by connect_artifacts; it is a named list of lists, each of which contains two keys: children and parents, which are character vectors with node identifiers matching names(graph). The traverse starts in each identifier passed in start (there can by multiple starting nodes). It uses neighbours to pick nodes to go to from any given node; this function accepts two arguments: id, a node identifier and graph which is the original graph structure.

Usage

1
traverse(graph, start, neighbours)

Arguments

graph

graph structure, as returned by connect_artifacts.

start

a vector of character node identifiers.

neighbours

a function which accepts a node identifier and the graph structure and returns a vector of node identifiers.

Value

a vector of node identifiers visited on the traverse.

See Also

ancestry_graph, adjust_ancestry

Examples

1
2
3
4
5
6
## Not run: 
   g <- ancestry_graph(...)
   # descend in a tree which start in the first node in the graph
   traverse(g, names(g)[[1]], function(id, graph) graph[[id]]$children)

## End(Not run)

lbartnik/repository documentation built on May 28, 2019, 9:50 a.m.