I don't even know where to begin on this one... I need help badly and I'll greatly appreciate any and all help that I can receive for this assignment. I've been looking over this program ever since it was assigned before Thanksgiving break and after wiping the slate clean and starting from scratch three times, I find myself turning to the gurus here at Tek-Tips for help.
The program (using stdlib.h) is as follows:
Consider the first graph, called "graph1"
int graph1[7][7] =
// 0 1 2 3 4 5 6
{ { BIG, 20, BIG, 10, 35, BIG, BIG }, // 0
{ 20, BIG, 30, 50, BIG, BIG, BIG }, // 1
{ BIG, 30, BIG, 40, BIG, BIG, BIG }, // 2
{ 10, 50, 40, BIG, 5, 35, BIG }, // 3
{ 35, BIG, BIG, 5, BIG, 15, 2 }, // 4
{ BIG, BIG, BIG, 35, 35, BIG, 3 }, // 5
{ BIG, BIG, BIG, BIG, BIG, 3, BIG } }; // 6
Note the constant used in the program:
const BIG = 2000000000;
This allows us to build an adjacency matrix of each graph where the "BIG" entry represents NO edge between vertices. Numbers smaller than BIG represent actual edges and weights of the edges.
Fully implement Joseph Kruskal's Algorithm for minimum spanning tree.
Remember that a spanning tree IS a graph. The output of your program should be in a text file ("Output.txt" and should be the form of an adjacency matrix. For example the output for the minimum spanning tree for graph1 is
BIG 20 BIG 10 BIG BIG BIG
20 BIG 30 BIG BIG BIG BIG
BIG 30 BIG BIG BIG BIG BIG
10 BIG BIG BIG 5 BIG BIG
BIG BIG BIG 5 BIG BIG 2
BIG BIG BIG BIG BIG BIG 3
BIG BIG BIG BIG 2 3 BIG
Because Kruskal tests for cycles, you'll have to use a version of a traversal algorithm. For example, if you are considering adding an edge between 4 and 2 but need to know if that would cause a cycle, test to see if 4 and 2 are already in the graph. If one is, that's fine, but not both.
That's it... again, I'd greatly appreciate any and all help that I can get on this one.
The program (using stdlib.h) is as follows:
Consider the first graph, called "graph1"
int graph1[7][7] =
// 0 1 2 3 4 5 6
{ { BIG, 20, BIG, 10, 35, BIG, BIG }, // 0
{ 20, BIG, 30, 50, BIG, BIG, BIG }, // 1
{ BIG, 30, BIG, 40, BIG, BIG, BIG }, // 2
{ 10, 50, 40, BIG, 5, 35, BIG }, // 3
{ 35, BIG, BIG, 5, BIG, 15, 2 }, // 4
{ BIG, BIG, BIG, 35, 35, BIG, 3 }, // 5
{ BIG, BIG, BIG, BIG, BIG, 3, BIG } }; // 6
Note the constant used in the program:
const BIG = 2000000000;
This allows us to build an adjacency matrix of each graph where the "BIG" entry represents NO edge between vertices. Numbers smaller than BIG represent actual edges and weights of the edges.
Fully implement Joseph Kruskal's Algorithm for minimum spanning tree.
Remember that a spanning tree IS a graph. The output of your program should be in a text file ("Output.txt" and should be the form of an adjacency matrix. For example the output for the minimum spanning tree for graph1 is
BIG 20 BIG 10 BIG BIG BIG
20 BIG 30 BIG BIG BIG BIG
BIG 30 BIG BIG BIG BIG BIG
10 BIG BIG BIG 5 BIG BIG
BIG BIG BIG 5 BIG BIG 2
BIG BIG BIG BIG BIG BIG 3
BIG BIG BIG BIG 2 3 BIG
Because Kruskal tests for cycles, you'll have to use a version of a traversal algorithm. For example, if you are considering adding an edge between 4 and 2 but need to know if that would cause a cycle, test to see if 4 and 2 are already in the graph. If one is, that's fine, but not both.
That's it... again, I'd greatly appreciate any and all help that I can get on this one.