Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
courses:cs211:winter2012:journals:jeanpaul:chapterthreesectionii [2012/01/31 00:05] – mugabej | courses:cs211:winter2012:journals:jeanpaul:chapterthreesectionii [2012/01/31 00:17] – mugabej | ||
---|---|---|---|
Line 12: | Line 12: | ||
* BFS produces a tree T rooted at s on the set of nodes reachable from s. | * BFS produces a tree T rooted at s on the set of nodes reachable from s. | ||
* For a BFS tree T, if x and y are nodes in T belonging to layers L< | * For a BFS tree T, if x and y are nodes in T belonging to layers L< | ||
+ | * The set of nodes discovered by the BFS algorithm is exactly those reachable from the starting node s: this set R is called the set of //connected component of G containing s//. | ||
+ | |||
+ | ==Algorithm== | ||
+ | |||
+ | Brief sketch:\\ | ||
+ | |||
+ | R* = set of connected components (a set of sets)\\ | ||
+ | while there is a node that does not belong to R*\\ | ||
+ | >>>>> | ||
+ | >>>>> | ||
+ | >>>>> | ||
+ | >>>>>>>>>> | ||
+ | >>>>> | ||
+ | >>>>> | ||
+ | end while\\ | ||
+ | |||
+ | The R produced at the end of the algorithm is the //connected component of G containing s//. The BFS algorithms is usually used when we need to order nodes we visit in successive layers based on their distance from s.\\ | ||
+ | ===Depth-First Search=== | ||
+ |