Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 31 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
31
Dung lượng
431,73 KB
Nội dung
Strongly Connected Components Tarjan's strongly connected components algorithm 13070274 – Nguyễn Anh Tuấn 13070262 – Lê Nguyễn Hoàng Thanh 13070244 – Nguyễn Thị Thuý Loan 13070242 – Trần Thạch Lam Outline Strongly connected component? Tarjan’s strongly connected components algorithm Applications Demonstration Outline Strongly connected component? Tarjan’s strongly connected components algorithm Applications Demonstration Strongly connected component? A strongly connected component of a directed graph G is a maximal set of vertices C V such that for every pair of vertices u and v, there is a directed path from u to v and a directed path from v to u Each vertex v is connected to itself This relation partitions V into disjoint sets that we call strongly connected components Strongly connected component? Some algorithms to compute strongly connected component Kosaraju’s two-pass algorithm, is named after S Rao Kosaraju, who described it, and then Micha Sharir later published it Tarjan’s algorithm, published by Robert Tarjan in 1972 The path-based strong component algorithm uses a depth first search, like Tarjan’s algorithm, but with two stack Outline Strongly connected component? Tarjan’s strongly connected components algorithm Applications Demonstration Tarjan’s algorithm The basic idea The Tarjan’s algorithm is based on depth first search (DFS) The vertices are indexed as they are traversed by DFS procedure Every vertex V gets assigned a vertex L as a representative while returning from the recursion of DFS Tarjan’s algorithm The basic idea (cont.) L is a vertex with the least index (low link) that can be reach from V Nodes with the same representative assigned are located in the same strongly connected component Tarjan’s algorithm Roots of components Components of the graph are just subtrees of the DFS tree To find components, we just have to break tree at certain edges A vertex is a “root” of a component if it’s the topmost The crucial has turned into determining whether a given vertex v is root How? A vertex is a root by looking for the existence of back or cross edges out of its subtree Tarjan’s algorithm - Pseudocode Tarjan’s algorithm - Example At node E E.index = E.lowlink = Push E into stack Stack = {E, D, C, B, A} SSC = {} For all descendants of E {F} Tarjan’s algorithm - Example At node E E.index = E.lowlink = Push E into stack Stack = {E, D, C, B, A} SSC = {} For all descendants of E {F} Tarjan’s algorithm - Example At node F F.index = F.lowlink = Push F into stack Stack = {F, E, D, C, B, A} SSC = {} For all descendants of F {C} Tarjan’s algorithm - Example At node C exist in stack Update parent node F of C F.lowlink = Update parent node E of F E.lowlink = Update parent node D of E D.lowlink = Update parent node C of D C.lowlink = Tarjan’s algorithm - Example At node C lowlink = index Pop {F, E, D, C} out of stack Stack = {B, A} SSC = {{F, E, D, C}} At node B lowlink = index Pop {B} from stack Stack = {A} SSC = {{F, E, D, C}, {B}} Tarjan’s algorithm - Example At node G G.index = G.lowlink = Push G into stack Stack = {G, A} SSC = {{F, E, D, C}, {B}} For all descendants of G {B, H} Tarjan’s algorithm - Example At node B doesn’t exist in stack Do nothing Stack = {G, A} SSC = {{F, E, D, C}, {B}} Tarjan’s algorithm - Example At node H H.index = H.lowlink = Push H into stack Stack = {H, G, A} SSC = {{F, E, D, C}, {B}} For all descendants of G {} Tarjan’s algorithm - Example At node H lowlink = index Pop {H}, Stack = {G, A} SSC = {{F, E, D, C}, {B}, {H}} At node G lowlink = index Pop {G}, Stack = {A} SSC = {{F, E, D, C}, {B}, {H}, {G}} At node A lowlink = index Pop {A}, Stack = {} SSC = {{F, E, D, C}, {B}, {H}, {G}, {A}} Tarjan’s algorithm - Example Outline Strongly connected component? Tarjan’s strongly connected components algorithm Applications Demonstration Applications Could to find groups of people who are more closely related in a huge set of data Think of Facebook and how they recommend people that might be your friends … Scheduling problem Outline Strongly connected component? Tarjan’s strongly connected components algorithm Applications Demonstration Demonstration Thanks for your attention! [...]... connected components algorithm 3 Applications 4 Demonstration Applications Could to find groups of people who are more closely related in a huge set of data Think of Facebook and how they recommend people that might be your friends … Scheduling problem Outline 1 Strongly connected component? 2 Tarjan’s strongly connected components algorithm 3 Applications 4 Demonstration Demonstration Thanks for your