As for the Kruskal algorithm in Ada, I'm not sure where to start.
I try to think over everything before writing a program, but am rather overlooked as to which data structures I should use and how to represent everything.
My initial thought is to represent a complete tree in an adjacency list, but reading Wikipedia, the algorithm points to create a forest F (a set of trees), where each vertex in the graph is a separate tree , and I'm not sure how to realize this without becoming really messy.
The next thing he says is create a set S containing all the edges in the graph , but once again I'm not sure what the best way to do this. I was thinking of an array of entries with to , from and weight , but I got lost in the forest .
Finally, I'm trying to figure out how I would know if an edge is connected to two trees, but again I'm not sure what is the best way to do all this.
cheezone
source share