KS-SCC — My Own Algorithm To Find SCC's

Revision en8, by Tabriz-Talayi, 2026-11-23 22:46:32

I was recently tasked with finding a way to calculate SCCs in a directed graph by a teacher expecting me to reach Tarjan's or Kosaraju's algorithm, but I reached a completely different and new solution (the novelty Im not fully sure).

It's arguably a bit worse in both simplicity and complexity, but I decided to write a blog about it anyway since I think I used some cool ideas, and who knows, maybe somebody else can utilize this either to find a useful variant or in some completely unrelated problem.

My teacher named it KS-SCC, hinting at the fact that it's dumb/useless (in Farsi), lmao.
But I think it's funny, so I will stick with it.


Prerequisites

Intuition & Proof of KS-SCC

Implementation of KS-SCC

KS-SCC Test Results (Complexity & Correctness)

I might have made a bigger deal out of this than it is but it was really fun for me to write this blog so I hope it was worthwhile.
I did not find anything similar by doing a quick search online but if anybody found an earlier discovery of the same solution they can share in the comments.

I checked everything I said multiple times to make sure whatever I said is correct, but I'm relatively in the beginning of my CP journey(8 months in) so if a more experienced coder can check what I said, I would truly appreciate it.

Also, I'm not technical enough and don't even think I have the required specs to run my own tests so I used ChatGPT for testing KS-SCC, and was overjoyed to see it outperformed Tarjan and Kosaraju at least for $$$n \lt = 10^5$$$ but I am not sure how trustworthy it is so if anybody is willing to test my code I will be eternally grateful.

This is the first version of KS-SCC and I did not spend much time on optimizing it, for instance I think the up[] array can be fully eliminated.

So I'm open to any and all suggestions for edits & optimization.

Tags algorithms, scc, dfs, dsu

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en11 English Tabriz-Talayi 2026-11-24 07:47:11 619 Tiny change: '*UPD1:**\nIm exami' -> '*UPD1:**\n<br>\nIm exami'
en10 English Tabriz-Talayi 2026-11-23 23:21:02 36
en9 English Tabriz-Talayi 2026-11-23 23:11:16 114 Tiny change: 'o.\n<br>\nBut I think it' -> 'o.\n<br>\nI think it'
en8 English Tabriz-Talayi 2026-11-23 22:46:32 33
en7 English Tabriz-Talayi 2026-11-23 22:39:28 19496 Tiny change: '------------------------' -> '----------' (published)
en6 English Tabriz-Talayi 2026-11-23 20:15:45 0 (saved to drafts)
en5 English Tabriz-Talayi 2026-11-23 20:15:32 4 (published)
en4 English Tabriz-Talayi 2026-11-23 20:14:43 6381
en3 English Tabriz-Talayi 2026-11-23 19:59:24 631 Tiny change: 'n.\n<br>\nIt' -> 'n.\n<br>\n<br>\nIt'
en2 English Tabriz-Talayi 2026-11-23 19:11:34 36612 Tiny change: '\n\n<br>\n<br>\n\n' -> '\n\n<br>\n\n'
en1 English Tabriz-Talayi 2026-11-23 17:07:54 4147 Initial revision (saved to drafts)