✅ 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
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]]
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
Okay I got it... I think
nice nice
I'll have to clean it up later, but for now it works