C
C#13mo ago
Thinker

✅ Implementing Tarjan's strongly connected components algorithm

So I'm trying to implement Tarjan's strongly connected components algorithm, an algorithm for generating strongly connected components from a graph. I already have a graph (a list of nodes), and I've tried to implement the algo, but it does not work as intended. And yes I'm using a struct to keep track of data associated with the nodes, sue me. https://paste.mod.gg/odfzzxyybahk/0
5 Replies
Thinker
Thinker13mo ago
If I give it a graph a -> b -> c -> b, it generates three components and not the expected two. oh and .Pairs() for [a, b, c, d] returns [[a, b], [b, c], [c, d]]
ZacharyPatten
ZacharyPatten13mo ago
do you have any unit tests? I'm sure I can help but not familiar with the algorithm off the top of my head so need to understand the purpose of the algo first
Thinker
Thinker13mo ago
Okay I got it... I think
ZacharyPatten
ZacharyPatten13mo ago
nice nice
Thinker
Thinker13mo ago
I'll have to clean it up later, but for now it works
Want results from more Discord servers?
Add your server