Kosaraju's algorithm

Kosaraju's algorithm

In computer science, Kosaraju's algorithm is an algorithm to find the strongly connected components of a directed graph. Aho, Hopcroft and Ullman credit it to an unpublished paper from 1978 by S. Rao Kosaraju. It makes use of the fact that the transpose graph (the same graph with the direction of every edge reversed) has exactly the same strongly connected components as the original graph.

Kosaraju's algorithm is simple and works as follows:
* Let G be a directed graph and S be an empty stack.
* While S does not contain all vertices:
** Choose an arbitrary vertex "v" not in S. Perform a depth-first search starting at "v". Each time that depth-first search finishes expanding a vertex "u", push "u" onto S.
* Reverse the directions of all arcs to obtain the transpose graph.
* While S is nonempty:
** Pop the top vertex "v" from S. Perform a depth-first search starting at "v". The set of visited vertices will give the strongly connected component containing "v"; record this and remove all these vertices from the graph G and the stack S.

Equivalently, breadth-first search (BFS) can be used instead of depth-first search.

Complexity

Provided the graph is described using an adjacency list, Kosaraju's algorithm performs two complete traversals of the graph and so runs in Θ(V+E) (linear) time, which is asymptotically optimal because there is a matching lower bound (any algorithm must examine all vertices and edges). It is the conceptually simplest efficient algorithm, but is not as efficient in practice as Tarjan's strongly connected components algorithm and Gabow's algorithm, which perform only one traversal of the graph.

If the graph is represented as an adjacency matrix, the algorithm requires "Ο(V2)" time.

References

* Alfred V. Aho, John E. Hopcroft, Jeffrey D. Ullman. "The Design and Analysis of Computer Algorithms". Addison-Wesley, 1974.
* Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein. "Introduction to Algorithms", 2nd edition. The MIT Press, 2001. ISBN 0-262-03293-7.

External links

* [http://lcm.csa.iisc.ernet.in/dsa/node171.html A description and proof of Kosaraju's Algorithm]
* [http://scienceblogs.com/goodmath/2007/10/computing_strongly_connected_c.php Good Math, Bad Math: Computing Strongly Connected Components]


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • S. Rao Kosaraju — Sambasiva Rao Kosaraju is a professor of Computer Science at Johns Hopkins University, who has done extensive work in the design and analysis of parallel and sequential algorithms.In 1978, he wrote a paper describing a method to efficiently… …   Wikipedia

  • Tarjan's strongly connected components algorithm — Tarjan s Algorithm (named for its discoverer, Robert Tarjan) is a graph theory algorithm for finding the strongly connected components of a graph. It can be seen as an improved version of Kosaraju s algorithm, and is comparable in efficiency to… …   Wikipedia

  • 2-satisfiability — In computer science, 2 satisfiability (abbreviated as 2 SAT or just 2SAT) is the problem of determining whether a collection of two valued (Boolean or binary) variables with constraints on pairs of variables can be assigned values satisfying all… …   Wikipedia

  • List of mathematics articles (K) — NOTOC K K approximation of k hitting set K ary tree K core K edge connected graph K equivalence K factor error K finite K function K homology K means algorithm K medoids K minimum spanning tree K Poincaré algebra K Poincaré group K set (geometry) …   Wikipedia

  • Strongly connected component — Graph with strongly connected components marked A directed graph is called strongly connected if there is a path from each vertex in the graph to every other vertex. In particular, this means paths in each direction; a path from a to b and also a …   Wikipedia

  • Algorithme de parcours en profondeur — L algorithme de parcours en profondeur (ou DFS, pour Depth First Search) est un algorithme de parcours de graphe qui se décrit naturellement de manière récursive. Son application la plus simple consiste à déterminer s il existe un chemin d un… …   Wikipédia en Français

  • Algorithme de Tarjan — En théorie des graphes, l algorithme de Tarjan permet de déterminer les composantes fortement connexes d un graphe orienté[1]. Il porte le nom de son inventeur, Robert Tarjan. L algorithme de Tarjan est de complexité linéaire, comme l algorithme… …   Wikipédia en Français

  • Composante fortement connexe — Décomposition d un graphe en composantes fortement connexes En théorie des graphes, une composante fortement connexe d un graphe orienté G est un sous graphe maximal de G tel que pour toute paire de sommets u et v dans ce sous graphe, il existe… …   Wikipédia en Français

  • Smith set — In voting systems, the Smith set is the smallest non empty set of candidates in a particular election such that each member beats every other candidate outside the set in a pairwise election. The Smith set provides one standard of optimal choice… …   Wikipedia

  • Schwartz set — In voting systems, the Schwartz set is the union of all Schwartz set components. A Schwartz set component is any non empty set S of candidates such that # Every candidate inside the set S is pairwise unbeaten by any candidate outside S ; and # No …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”