<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Path-based_strong_component_algorithm</id>
	<title>Path-based strong component algorithm - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Path-based_strong_component_algorithm"/>
	<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Path-based_strong_component_algorithm&amp;action=history"/>
	<updated>2026-06-23T04:03:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>http://70.231.62.181/index.php?title=Path-based_strong_component_algorithm&amp;diff=14021215&amp;oldid=prev</id>
		<title>imported&gt;JJMC89 bot III: Moving :Category:Algorithms in graph theory to :Category:Graph algorithms per Wikipedia:Categories for discussion/Log/2024 October 4</title>
		<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Path-based_strong_component_algorithm&amp;diff=14021215&amp;oldid=prev"/>
		<updated>2024-10-12T19:57:36Z</updated>

		<summary type="html">&lt;p&gt;Moving &lt;a href=&quot;/index.php?title=Category:Algorithms_in_graph_theory&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:Algorithms in graph theory (page does not exist)&quot;&gt;Category:Algorithms in graph theory&lt;/a&gt; to &lt;a href=&quot;/index.php/Category:Graph_algorithms&quot; title=&quot;Category:Graph algorithms&quot;&gt;Category:Graph algorithms&lt;/a&gt; per &lt;a href=&quot;https://en.wikipedia.org/wiki/Categories_for_discussion/Log/2024_October_4&quot; class=&quot;extiw&quot; title=&quot;wikipedia:Categories for discussion/Log/2024 October 4&quot;&gt;Wikipedia:Categories for discussion/Log/2024 October 4&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Graph algorithm}}&lt;br /&gt;
In [[graph theory]], the [[strongly connected component]]s of a [[directed graph]] may be found using an algorithm that uses [[depth-first search]] in combination with two [[stack (data structure)|stacks]], one to keep track of the vertices in the current component and the second to keep track of the current search path.&amp;lt;ref&amp;gt;{{harvtxt|Sedgewick|2004}}.&amp;lt;/ref&amp;gt; Versions of this algorithm have been proposed by {{harvtxt|Purdom|1970}}, {{harvtxt|Munro|1971}}, {{harvtxt|Dijkstra|1976}}, {{harvtxt|Cheriyan|Mehlhorn|1996}}, and {{harvtxt|Gabow|2000}}; of these, Dijkstra&amp;#039;s version was the first to achieve [[linear time]].&amp;lt;ref&amp;gt;[http://www.cs.colorado.edu/~hal/Papers/DFS/pbDFShistory.html History of Path-based DFS for Strong Components], Harold N. Gabow, accessed 2012-04-24.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
The algorithm performs a depth-first search of the given graph &amp;#039;&amp;#039;G&amp;#039;&amp;#039;, maintaining as it does two stacks &amp;#039;&amp;#039;S&amp;#039;&amp;#039; and &amp;#039;&amp;#039;P&amp;#039;&amp;#039; (in addition to the normal call stack for a recursive function).&lt;br /&gt;
Stack &amp;#039;&amp;#039;S&amp;#039;&amp;#039; contains all the vertices that have not yet been assigned to a strongly connected component, in the order in which the depth-first search reaches the vertices.&lt;br /&gt;
Stack &amp;#039;&amp;#039;P&amp;#039;&amp;#039; contains vertices that have not yet been determined to belong to different strongly connected components from each other. It also uses a counter &amp;#039;&amp;#039;C&amp;#039;&amp;#039; of the number of vertices reached so far, which it uses to compute the preorder numbers of the vertices.&lt;br /&gt;
&lt;br /&gt;
When the depth-first search reaches a vertex &amp;#039;&amp;#039;v&amp;#039;&amp;#039;, the algorithm performs the following steps:&lt;br /&gt;
#Set the preorder number of &amp;#039;&amp;#039;v&amp;#039;&amp;#039; to &amp;#039;&amp;#039;C&amp;#039;&amp;#039;, and increment &amp;#039;&amp;#039;C&amp;#039;&amp;#039;.&lt;br /&gt;
#Push &amp;#039;&amp;#039;v&amp;#039;&amp;#039; onto &amp;#039;&amp;#039;S&amp;#039;&amp;#039; and also onto &amp;#039;&amp;#039;P&amp;#039;&amp;#039;.&lt;br /&gt;
#For each edge from &amp;#039;&amp;#039;v&amp;#039;&amp;#039; to a neighboring vertex &amp;#039;&amp;#039;w&amp;#039;&amp;#039;:&lt;br /&gt;
#* If the preorder number of &amp;#039;&amp;#039;w&amp;#039;&amp;#039; has not yet been assigned (the edge is a [[Depth-first search#Output of a depth-first search|tree edge]]), recursively search &amp;#039;&amp;#039;w&amp;#039;&amp;#039;;&lt;br /&gt;
#*Otherwise, if &amp;#039;&amp;#039;w&amp;#039;&amp;#039; has not yet been assigned to a strongly connected component (the edge is a forward/back/cross edge):&lt;br /&gt;
#**Repeatedly pop vertices from &amp;#039;&amp;#039;P&amp;#039;&amp;#039; until the top element of &amp;#039;&amp;#039;P&amp;#039;&amp;#039; has a preorder number less than or equal to the preorder number of &amp;#039;&amp;#039;w&amp;#039;&amp;#039;.&lt;br /&gt;
#If &amp;#039;&amp;#039;v&amp;#039;&amp;#039; is the top element of &amp;#039;&amp;#039;P&amp;#039;&amp;#039;:&lt;br /&gt;
#*Pop vertices from &amp;#039;&amp;#039;S&amp;#039;&amp;#039; until &amp;#039;&amp;#039;v&amp;#039;&amp;#039; has been popped, and assign the popped vertices to a new component.&lt;br /&gt;
#*Pop &amp;#039;&amp;#039;v&amp;#039;&amp;#039; from &amp;#039;&amp;#039;P&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The overall algorithm consists of a loop through the vertices of the graph, calling this recursive search on each vertex that does not yet have a preorder number assigned to it.&lt;br /&gt;
&lt;br /&gt;
==Related algorithms==&lt;br /&gt;
Like this algorithm, [[Tarjan&amp;#039;s strongly connected components algorithm]] also uses depth first search together with a stack to keep track of vertices that have not yet been assigned to a component, and moves these vertices into a new component when it finishes expanding the final vertex of its component. However, in place of the stack &amp;#039;&amp;#039;P&amp;#039;&amp;#039;, Tarjan&amp;#039;s algorithm uses  a vertex-indexed [[array (data type)|array]] of preorder numbers, assigned in the order that vertices are first visited in the [[depth-first search]]. The preorder array is used to keep track of when to form a new component.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*{{citation&lt;br /&gt;
 | last1 = Cheriyan | first1 = J.&lt;br /&gt;
 | last2 = Mehlhorn | first2 = K. | author2-link = Kurt Mehlhorn&lt;br /&gt;
 | doi = 10.1007/BF01940880&lt;br /&gt;
 | journal = [[Algorithmica]]&lt;br /&gt;
 | pages = 521–549&lt;br /&gt;
 | title = Algorithms for dense graphs and networks on the random access computer&lt;br /&gt;
 | volume = 15&lt;br /&gt;
 | year = 1996| issue = 6&lt;br /&gt;
 | s2cid = 8930091&lt;br /&gt;
 }}.&lt;br /&gt;
*{{citation&lt;br /&gt;
 | last = Dijkstra | first = Edsger | author-link = Edsger Dijkstra&lt;br /&gt;
 | location = NJ&lt;br /&gt;
 | at = Ch.&amp;amp;nbsp;25&lt;br /&gt;
 | publisher = Prentice Hall&lt;br /&gt;
 | title = A Discipline of Programming&lt;br /&gt;
 | year = 1976}}.&lt;br /&gt;
*{{citation&lt;br /&gt;
 | last = Gabow | first = Harold N. | author-link = Harold N. Gabow&lt;br /&gt;
 | doi = 10.1016/S0020-0190(00)00051-X&lt;br /&gt;
 | issue = 3–4&lt;br /&gt;
 | journal = Information Processing Letters&lt;br /&gt;
 | mr = 1761551&lt;br /&gt;
 | pages = 107–114&lt;br /&gt;
 | title = Path-based depth-first search for strong and biconnected components&lt;br /&gt;
 | volume = 74&lt;br /&gt;
 | year = 2000&lt;br /&gt;
 | url = https://www.cs.princeton.edu/courses/archive/spr04/cos423/handouts/path%20based...pdf}}.&lt;br /&gt;
*{{citation&lt;br /&gt;
 | last = Munro | first = Ian | author-link = Ian Munro (computer scientist)&lt;br /&gt;
 | journal = Information Processing Letters&lt;br /&gt;
 | pages = 56–58&lt;br /&gt;
 | title = Efficient determination of the transitive closure of a directed graph&lt;br /&gt;
 | volume = 1&lt;br /&gt;
 | year = 1971&lt;br /&gt;
 | issue = 2&lt;br /&gt;
 | doi=10.1016/0020-0190(71)90006-8}}.&lt;br /&gt;
*{{citation&lt;br /&gt;
 | last = Purdom | first = P. Jr.&lt;br /&gt;
 | journal = BIT&lt;br /&gt;
 | pages = 76–94&lt;br /&gt;
 | title = A transitive closure algorithm&lt;br /&gt;
 | volume = 10&lt;br /&gt;
 | year = 1970&lt;br /&gt;
 | doi=10.1007/bf01940892| s2cid = 20818200&lt;br /&gt;
 | url = http://digital.library.wisc.edu/1793/57514&lt;br /&gt;
 }}.&lt;br /&gt;
*{{citation&lt;br /&gt;
 | last = Sedgewick | first = R.&lt;br /&gt;
 | contribution = 19.8 Strong Components in Digraphs&lt;br /&gt;
 | edition = 3rd&lt;br /&gt;
 | location = Cambridge MA&lt;br /&gt;
 | pages = 205–216&lt;br /&gt;
 | publisher = Addison-Wesley&lt;br /&gt;
 | title = Algorithms in Java, Part 5 – Graph Algorithms&lt;br /&gt;
 | year = 2004}}.&lt;br /&gt;
&lt;br /&gt;
[[Category:Graph algorithms]]&lt;br /&gt;
[[Category:Graph connectivity]]&lt;/div&gt;</summary>
		<author><name>imported&gt;JJMC89 bot III</name></author>
	</entry>
</feed>