powered by
Finds the elements in the component of root
root
dfs(adj, root)
All nodes connected to root
A named adjacency list of a decomposable grah
The node from which the component should be found
x <- list(a = c("b", "d"), b = c("a", "d"), c = c("b", "a"), d = c("e", "f"), e = c("d", "f"), f = c("d", "e")) dfs(x, "a")
Run the code above in your browser using DataLab