Last chance! 50% off unlimited learning
Sale ends in
graph
and a node
to start from. It returns a
standard vertex labeling of graph
. This is a vector with
elements corresponding to the nodes of graph
and with values
that correspond to point in the depth first search the node is
visited.
DFS(object, node, checkConn=TRUE)
graph
class. character
indicating the starting node. logical
indicating whether the connectivity
of the graph should be checked. graph
whose values
are 0
to one less than the number of nodes. These indices
indicate the point at which the node will be visited.
It requires that the graph be connected. By default, this is checked, but since the checking can be expensive it is optional.
A faster and mostly likely better implementation of depth first
searching is given by dfs
in the RBGL
package.
boundary
RNGkind("Mersenne-Twister")
set.seed(123)
g1 <- randomGraph(letters[1:10], 1:4, p=.3)
RNGkind()
DFS(g1, "a")
Run the code above in your browser using DataLab