bfs {RBGL}R Documentation

Breadth and Depth-first search

Description

These functions carry out breadth and depth first search using routines from the BOOST library. For dfs a list containing two vectors is returned. These indicate the sequence in which a node is first visited and last visited. For dfs a single vector is returned indicating the order in which a node was visited.

Usage

bfs(graph, init.node=1, checkConn=FALSE)
## S4 method for signature 'graph':
dfs(graph)
## S4 method for signature 'graph':
bfs(graph)

Arguments

graph instance of class graph from Bioconductor graph class
init.node index (1 based) of where to start search
checkConn logical indicating whether connectivity of input graph should be checked

Details

calls to boost bfs or dfs procedures

Value

for bfs: vector of indices in order of BFS visit
for dfs: list of two vectors of nodes, order of DFS discovery, and order of DFS completion (finish)

Author(s)

VJ Carey <stvjc@channing.harvard.edu>

Examples

dd <- fromGXL(file(system.file("XML/bfsex.gxl",package="RBGL")))
dd@edgemode <- "undirected"
bfs(dd)
bfs(dd,2)

dd <- fromGXL(file(system.file("XML/dfsex.gxl",package="RBGL")))
dfs(dd)

[Package Contents]