Kruskal\'s algorthim C++ Write a C++ program for the implementation of an algori
ID: 3774490 • Letter: K
Question
Kruskal's algorthim C++
Write a C++ program for the implementation of an algorithm to find a minimal spanning tree Kruskal's algorithm using the data structure Disjoint set The first line will be the number of nodes, N, in the graph. Each node will be identified uniquely by a number 1-N inclusively. After the number of nodes in the graph, the edges of the graph will be given, one edge per line. The edges will be denoted by their two nodes and it's weight each separated by one space. An example of an input files follows:Explanation / Answer
/************************************************************ -> This Program is to implement Kruskal algorithm. -> This program is to find minimum spanning tree for undirected weighted graphs -> Data Structers used: Graph:Adjacency Matrix -> This program works in microsoft vc++ 6.0 environment. **************************************************************/ #include #include using namespace std; class kruskal { private: int n; //no of nodes int noe; //no edges in the graph int graph_edge[100][4]; int tree[10][10]; int sets[100][10]; int top[100]; public: int read_graph(); void initialize_span_t(); void sort_edges(); void algorithm(); int find_node(int ); void print_min_span_t(); }; int kruskal::read_graph() { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.