1 / 107

Advanced algorithms strongly connected components algorithm s, Euler trail , Hamiltonian path

This algorithm finds the strongly connected components in a directed graph using the Kosaraju-Sharir algorithm.

kweiss
Download Presentation

Advanced algorithms strongly connected components algorithm s, Euler trail , Hamiltonian path

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced algorithms strongly connected components algorithms, Euler trail, Hamiltonian path Jiří Vyskočil, Radek Mařík 2013

  2. Connected component b C(a)=C(b)={a,b} c a C(c) =C(d) =C(e)={c,d,e} d e A connected component of graphG =(V,E ) with regard to vertex vis a set C(v ) = {u∈V | there exists a pathin G fromutov }. In other words: If a graph is disconnected, then parts from which is composed from and that are themselves connected, are called connected components.

  3. Strongly Connected Components[silně souvislé komponenty] a b c d e f g h A directed graph G =(V,E )is called strongly connected if there is a path in each direction between every couple of vertices in the graph. The strongly connected components of a directed graph G are its maximal strongly connected subgraphs. SCC(v ) = {u∈V | there exists a pathin G fromutov and a pathin G fromvtou}

  4. Kosaraju-SharirAlgorithm input: graph G = (V, E ) output: set of strongly connected components (sets of vertices) • S = empty stack; • whileS does not contain all vertices do Choose an arbitrary vertex v not in S; DFS-Walk’(v ) and each time that DFS finishes expanding a vertex u, push u onto S; • Reverse the directions of all arcs to obtain the transpose graph; • whileS is nonempty do v = pop(S); ifv is UNVISITED then DFS-Walk(v ); The set of visited vertices will give the strongly connected component containing v;

  5. DFS-Walk • input:Graph G. • procedure DFS-Walk(Vertex u ) { • state[u ] = OPEN; d[u ] = ++time; • for each Vertexvin succ(u ) • if (state[v ] == UNVISITED) then{p[v ] = u; DFS-Walk(v ); } • state[u ] = CLOSED; f[u ] = ++time; • } • procedure DFS-Walk’(Vertex u ) { • state[u ] = OPEN; d[u ] = ++time; • for each Vertexvin succ(u ) • if (state[v ] == UNVISITED) then{p[v ] = u; DFS-Walk’(v ); } • state[u ] = CLOSED; f[u ] = ++time; push u to S; • } • output: arrayppointing to predecessor vertex, array dwith times of vertex opening and array fwith time of vertex closing.

  6. DFS-Walk - optimized • input:Graph G. • procedure DFS-Walk(Vertex u ) { • state[u ] = OPEN; • for each Vertexvin succ(u ) • if (state[v ] == UNVISITED) thenDFS-Walk(v ); • state[u ] = CLOSED; • } • procedure DFS-Walk’(Vertex u ) { • state[u ] = OPEN; • for each Vertexvin succ(u ) • if (state[v ] == UNVISITED) thenDFS-Walk’(v ); • state[u ] = CLOSED; push u to S; • }

  7. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  8. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  9. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  10. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  11. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  12. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  13. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  14. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  15. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  16. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  17. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  18. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  19. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  20. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  21. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  22. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  23. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  24. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  25. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  26. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  27. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  28. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  29. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  30. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  31. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  32. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  33. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  34. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  35. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  36. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  37. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  38. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  39. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  40. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  41. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  42. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  43. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  44. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  45. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  46. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  47. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  48. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  49. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

  50. Kosaraju-SharirAlgorithm a b c d e f g h OPEN CLOSED UNVISITED

More Related