


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
There are two standard (and simple) ways of traversing all vertices/edges in a graph in a systematic way: BFS and DFS. • Most fundamental algorithms on ...
Typology: Schemes and Mind Maps
1 / 4
This page cannot be seen from the preview
Don't miss anything!
The most fundamental graph problem is traversing the graph.
BFS(s) color[s] = gray d[s] = 0 ENQUEUE(Q, s) WHILE Q not empty DO DEQUEUE(Q, u) FOR each v ∈ adj[u] DO IF color[v] = white THEN color[v] = gray d[v] = d[u] + 1 parent[v] = u //(u,v) is a tree-edge ENQUEUE(Q, v) //ELSE v is not white, (u,v) is non-tree edge color[u] = black
FOR each vertex u ∈ V DO IF color[u] = white THEN BFS(u)
DFS Properties: