- Apr 10, 2006
- 12,028
- 2
- 0
I'm doing a project to compare the running times between Kruskal's and Prim-Jarnik algorithms. I'm a little lost on where to start in constructing a graph.
I think I need a priority queue or heap to store the egdes and possibly a linked list to store vertices that I've already gone through. I'm a bit confused of how to store the distance and the vertices in the queue. Would an array of structs that stored the vertices and distances work in a queue, and just order it by the distance? I just don't understand how to get from the graph to the queue.
Also, would it be easier to do an adjacency list or matrix to originally store the graph? An adjacency list would be a list of distances pointing to a list of vertices, correct? How could I read that in easily (file input)?
I know an adjacency matrix would just be a 2d array, but how would I get it to the queue? Same applies for the adj. list.
Sorry for all the ambiguous questions, I was sick for a few days and missed some class, and the book hasn't been too much help in showing how to implement things. I need to do well on this project or I'm going to fail the class.
Any help would be greatly appreciated.
I think I need a priority queue or heap to store the egdes and possibly a linked list to store vertices that I've already gone through. I'm a bit confused of how to store the distance and the vertices in the queue. Would an array of structs that stored the vertices and distances work in a queue, and just order it by the distance? I just don't understand how to get from the graph to the queue.
Also, would it be easier to do an adjacency list or matrix to originally store the graph? An adjacency list would be a list of distances pointing to a list of vertices, correct? How could I read that in easily (file input)?
I know an adjacency matrix would just be a 2d array, but how would I get it to the queue? Same applies for the adj. list.
Sorry for all the ambiguous questions, I was sick for a few days and missed some class, and the book hasn't been too much help in showing how to implement things. I need to do well on this project or I'm going to fail the class.
Any help would be greatly appreciated.
