instance of class graph from Bioconductor graph class
node
node name where search starts; defaults to the
node in first position in the node vector.
checkConn
logical for backwards compatibility; this
parameter has no effect as of RBGL 1.7.9 and will be removed in future versions.
Details
These two functions are interfaces to the BOOST graph library functions for
breadth first and depth first search. Both methods handle unconnected graphs
by applying the algorithms over the connected components.
Cormen et al note (p 542) that 'results of depth-first search
may depend upon the order in which the vertices are examined ...
These different visitation orders tend not to cause problems
in practice, as any DFS result can usually be used effectively,
with essentially equivalent results'.
Value
For bfs a vector of node indices in order of BFS visit.
For dfs a list of two vectors of nodes, with elements discover
(order of DFS discovery), and finish (order of DFS completion).
The Boost Graph Library: User Guide and Reference Manual;
by Jeremy G. Siek, Lie-Quan Lee, and Andrew Lumsdaine;
(Addison-Wesley, Pearson Education Inc., 2002), xxiv+321pp.
ISBN 0-201-72914-8
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(RBGL)
Loading required package: graph
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/RBGL/bfs.Rd_%03d_medium.png", width=480, height=480)
> ### Name: bfs
> ### Title: Breadth and Depth-first search
> ### Aliases: bfs dfs dfs,graph,character,ANY-method
> ### bfs,graph,character,logical-method dfs,graph,character,logical-method
> ### bfs,graph,missing,logical-method bfs,graph,character,missing-method
> ### dfs,graph,character,missing-method bfs,graph,missing,missing-method
> ### dfs,graph,missing,missing-method bfs,graph-method
> ### bfs,graph,character-method dfs,graph,character-method
> ### bfs,graph,ANY,ANY-method
> ### Keywords: graphs
>
> ### ** Examples
>
> con1 <- file(system.file("XML/bfsex.gxl",package="RBGL"), open="r")
> dd <- fromGXL(con1)
> close(con1)
>
> bfs(dd, "r")
[1] "r" "s" "v" "w" "t" "x" "u" "y"
> bfs(dd, "s")
[1] "s" "w" "r" "t" "x" "v" "u" "y"
>
> con2 <- file(system.file("XML/dfsex.gxl",package="RBGL"), open="r")
> dd2 <- fromGXL(con2)
> close(con2)
>
> dfs(dd2, "u")
$discovered
[1] "u" "v" "y" "x" "w" "z"
$finish
[1] "x" "y" "v" "u" "z" "w"
>
>
>
>
>
> dev.off()
null device
1
>