@@ -15,11 +15,13 @@ module mir.graph.tarjan;
1515import std.traits ;
1616
1717/+ +
18- Tarjan's strongly connected components algorithm.
18+ Classic Tarjan's strongly connected components algorithm.
1919
2020Tarjan's algorithm is an algorithm in graph theory for finding the strongly connected components of a graph.
2121It runs in linear time, matching the time bound for alternative methods including Kosaraju's algorithm and the path-based strong component algorithm.
2222
23+ The implementation is loop based. It does not use recursion and does not have stack overflow issues.
24+
2325Complexity: worst-case `O(|V| + |E|)`.
2426
2527Params:
@@ -209,7 +211,7 @@ auto tarjan(G, I = Unqual!(ForeachType!(ForeachType!G)))(G graph)
209211 0 -> 1 -> 2 -> 3 -> 10 9 <---
210212------
211213+/
212- @safe pure version(mir_test) unittest
214+ pure version (mir_test) unittest
213215{
214216 import mir.graph.utility;
215217 import mir.ndslice.algorithm: each;
@@ -244,9 +246,9 @@ auto tarjan(G, I = Unqual!(ForeachType!(ForeachType!G)))(G graph)
244246}
245247
246248/+ +
247- Tests that the graph `0 -> 1 -> 2 -> 3 -> 4`` returns 4 components.
249+ Tests that the graph `0 -> 1 -> 2 -> 3 -> 4` returns 4 components.
248250+/
249- @safe pure version(mir_test) unittest
251+ pure version (mir_test) unittest
250252{
251253 import mir.graph.utility;
252254
@@ -276,7 +278,7 @@ Tests that the graph `0 -> 1 -> 2 -> 3 -> 4`` returns 4 components.
276278 1 <- 3 <-> 4 <-- 7 <--(links to self)
277279----
278280+/
279- @safe pure version(mir_test) unittest
281+ pure version (mir_test) unittest
280282{
281283 import mir.graph.utility;
282284 import mir.ndslice.algorithm: each;
@@ -313,7 +315,7 @@ Tests that the graph `0 -> 1 -> 2 -> 3 -> 4`` returns 4 components.
313315 0
314316-----
315317+/
316- @safe pure version(mir_test) unittest
318+ pure version (mir_test) unittest
317319{
318320 import mir.graph.utility;
319321 import mir.ndslice.algorithm: each;
@@ -341,7 +343,7 @@ This test demonstrates a hard to detect bug, where vertices
341343were being marked 'off-stack' after they were first visited,
342344not when they were actually removed from the stack
343345+/
344- @safe pure version(mir_test) unittest
346+ pure version (mir_test) unittest
345347{
346348 import mir.graph.utility;
347349 import mir.ndslice.algorithm: each;
0 commit comments