<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>spanning tree | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/spanning-tree/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Thu, 11 Mar 2010 16:56:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C++ programs to implement the Kruskal’s algorithm to generate a minimum cost spanning tree</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-programs-to-implement-the-kruskal%e2%80%99s-algorithm-to-generate-a-minimum-cost-spanning-tree/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-programs-to-implement-the-kruskal%e2%80%99s-algorithm-to-generate-a-minimum-cost-spanning-tree/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 11 Mar 2010 16:56:57 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[spanning tree]]></category>
		<category><![CDATA[Kruskal’s algorithm]]></category>
		<category><![CDATA[minimum cost]]></category>
		<category><![CDATA[programes]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1024</guid>

					<description><![CDATA[<p>/* Write C++ programs to implement the Kruskal’s algorithm to generate a minimum cost spanning tree */ #include #include #include using namespace std; int cost[10][10],i,j,k,n,m,c,visit,visited[10],l,v,count,count1,vst,p; main() { int dup1,dup2; cout n; cout m; cout >j >>c; cost[i][j]=c; cost[j][i]=c; } for(i=1;i</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-programs-to-implement-the-kruskal%e2%80%99s-algorithm-to-generate-a-minimum-cost-spanning-tree/">C++ programs to implement the Kruskal’s algorithm to generate a minimum cost spanning tree</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write C++ programs to implement the Kruskal’s algorithm to generate a minimum cost spanning tree */</p>
<pre lang="cpp">
#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int cost[10][10],i,j,k,n,m,c,visit,visited[10],l,v,count,count1,vst,p;

main()
{
int dup1,dup2;
cout<<"enter no of vertices";
cin >> n;
cout <<"enter no of edges";
cin >>m;
cout <<"EDGE Cost";
for(k=1;k<=m;k++)
{
cin >>i >>j >>c;
cost[i][j]=c;
cost[j][i]=c;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(cost[i][j]==0)
cost[i][j]=31999;
visit=1;
while(visit<n)
{
v=31999;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(cost[i][j]!=31999 &#038;&#038; cost[i][j]<v  &#038;&#038; cost[i][j]!=-1 )
{
int count =0;
for(p=1;p<=n;p++)
{
if(visited[p]==i || visited[p]==j)
count++;
}
if(count >= 2)
{
for(p=1;p<=n;p++)
if(cost[i][p]!=31999 &#038;&#038; p!=j)
dup1=p;
for(p=1;p<=n;p++)
if(cost[j][p]!=31999 &#038;&#038; p!=i)
dup2=p;

if(cost[dup1][dup2]==-1)
continue;
}
l=i;
k=j;
v=cost[i][j];
}
cout <<"edge from " <<l <<"-->"<<k;
cost[l][k]=-1;
cost[k][l]=-1;
visit++;
int count=0;
count1=0;
for(i=1;i<=n;i++)
{
if(visited[i]==l)
count++;
if(visited[i]==k)
count1++;
} 
if(count==0)
visited[++vst]=l;
if(count1==0)
visited[++vst]=k;
}
}
</pre>
<p><strong>OUTPUT</strong></p>
<p>enter no of vertices4<br />
enter no of edges4<br />
EDGE Cost<br />
1 2 1<br />
2 3 2<br />
3 4 3<br />
1 3 3</p>
<p>edge from 1-->2edge from 2-->3edge from 1-->3</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-programs-to-implement-the-kruskal%e2%80%99s-algorithm-to-generate-a-minimum-cost-spanning-tree/">C++ programs to implement the Kruskal’s algorithm to generate a minimum cost spanning tree</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-programs-to-implement-the-kruskal%e2%80%99s-algorithm-to-generate-a-minimum-cost-spanning-tree/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>C++ programs to implement the Prim’s algorithm to generate a minimum cost spanning tree</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-programs-to-implement-the-prim%e2%80%99s-algorithm-to-generate-a-minimum-cost-spanning-tree/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-programs-to-implement-the-prim%e2%80%99s-algorithm-to-generate-a-minimum-cost-spanning-tree/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 11 Mar 2010 16:53:26 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[Prim’s algorithm]]></category>
		<category><![CDATA[spanning tree]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1021</guid>

					<description><![CDATA[<p>/* Write C++ programs to implement the Prim’s algorithm to generate a minimum cost spanning tree */ #include #include #include using namespace std; int cost[10][10],i,j,k,n,stk[10],top,v,visit[10],visited[10],u; main() { int m,c; cout n; cout m; cout >j>>c; cost[i][j]=c; } for(i=1;i</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-programs-to-implement-the-prim%e2%80%99s-algorithm-to-generate-a-minimum-cost-spanning-tree/">C++ programs to implement the Prim’s algorithm to generate a minimum cost spanning tree</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write C++ programs to implement the Prim’s algorithm to generate a minimum cost spanning tree */</p>
<pre lang="cpp">
#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int cost[10][10],i,j,k,n,stk[10],top,v,visit[10],visited[10],u;

main()
{
	int m,c;
	cout <<"enterno of vertices";
	cin >> n;
	cout <<"ente no of edges";
	cin >> m;
	cout <<"\nEDGES Cost\n";
	for(k=1;k<=m;k++)
	{
		cin >>i>>j>>c;
		cost[i][j]=c;
	}
	for(i=1;i<=n;i++)
	for(j=1;j<=n;j++)
		if(cost[i][j]==0)
		cost[i][j]=31999;

	cout <<"ORDER OF VISITED VERTICES";
	k=1;
	while(k<n)
	{
		m=31999;
		if(k==1)
		{
			for(i=1;i<=n;i++)
				for(j=1;j<=m;j++)
				if(cost[i][j]<m)
				{
					m=cost[i][j];
					u=i;
				}
		}
		else
		{
			for(j=n;j>=1;j--)
			if(cost[v][j]<m &#038;&#038; visited[j]!=1 &#038;&#038; visit[j]!=1)
			{
				visit[j]=1;
				stk[top]=j;
				top++;
				m=cost[v][j];
				u=j;
			}
		}
		cost[v][u]=31999;
		v=u;
		cout<<v << " ";
		k++;
		visit[v]=0; visited[v]=1;
	}
}
</pre>
<p><strong>OUTPUT</strong></p>
<p>enterno of vertices7<br />
ente no of edges9</p>
<p>EDGES Cost<br />
1 6 10<br />
6 5 25<br />
5 4 22<br />
4 3 12<br />
3 2 16<br />
2 7 14<br />
5 7 24<br />
4 7 18<br />
1 2 28<br />
ORDER OF VISITED VERTICES1 6 5 4 3 2</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-programs-to-implement-the-prim%e2%80%99s-algorithm-to-generate-a-minimum-cost-spanning-tree/">C++ programs to implement the Prim’s algorithm to generate a minimum cost spanning tree</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-programs-to-implement-the-prim%e2%80%99s-algorithm-to-generate-a-minimum-cost-spanning-tree/feed/</wfw:commentRss>
			<slash:comments>26</slash:comments>
		
		
			</item>
	</channel>
</rss>
