Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#include
using namespace std;
class disjointset
{
public:
int djset[20];
};
class edge
{
public:
int v1;
int v2;
int wt;
};
class graph
{
public:
int v;
int e;
edge ed[20];
};
void graph::sort_edges()
{
edge temp;
for(int i=0;i<e;i++)
{
for(int j=0;j<e-i-1;j++)
{
if(ed[j].wt > ed[j+1].wt)
{
temp.v1 = ed[j].v1;
temp.v2 = ed[j].v2;
temp.wt = ed[j].wt;
}
void graph::kruskal_mst()
{
edge mst[20];
int mst_ctr = 0;
int mst_cost = 0;
disjointset dj(v);
sort_edges();
cout<<"\n Edges after sorting: ";
display_graph();
cout<<"\n";
}
void graph::accept_graph()
{
for(int i=0;i<e;i++)
{
cout<<"\n Enter v1 :";
cin>>ed[i].v1;
cout<<"\n Enter v2 :";
cin>>ed[i].v2;
cout<<"\n Enter weight :";
cin>>ed[i].wt;
}
}
void graph::display_graph()
{
for(int i=0;i<e;i++)
{
cout<<"\n "<<ed[i].v1<<" "<<ed[i].v2<<" "<<ed[i].wt;
}
}
int main() //Main Function
{
}