<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://gatecse.in/w/index.php?action=history&amp;feed=atom&amp;title=Kruskal_Algorithm_Implementation_in_C%2FC%2B%2B</id>
		<title>Kruskal Algorithm Implementation in C/C++ - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://gatecse.in/w/index.php?action=history&amp;feed=atom&amp;title=Kruskal_Algorithm_Implementation_in_C%2FC%2B%2B"/>
		<link rel="alternate" type="text/html" href="https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;action=history"/>
		<updated>2026-04-16T14:03:16Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.27.0</generator>

	<entry>
		<id>https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;diff=2508&amp;oldid=prev</id>
		<title>Arjun Suresh at 16:37, 22 February 2014</title>
		<link rel="alternate" type="text/html" href="https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;diff=2508&amp;oldid=prev"/>
				<updated>2014-02-22T16:37:58Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;tr style=&#039;vertical-align: top;&#039; lang=&#039;en&#039;&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 16:37, 22 February 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;C&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot; name=&amp;quot;kruskal&lt;/ins&gt;&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include&amp;lt;iostream&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include&amp;lt;iostream&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;using namespace std;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;using namespace std;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Arjun Suresh</name></author>	</entry>

	<entry>
		<id>https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;diff=2281&amp;oldid=prev</id>
		<title>Arjun Suresh: Arjun Suresh moved page Kruskal Algorithm Implementation in C\C++ to Kruskal Algorithm Implementation in C/C++</title>
		<link rel="alternate" type="text/html" href="https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;diff=2281&amp;oldid=prev"/>
				<updated>2014-01-28T21:01:01Z</updated>
		
		<summary type="html">&lt;p&gt;Arjun Suresh moved page &lt;a href=&quot;/wiki/Kruskal_Algorithm_Implementation_in_C%5CC%2B%2B&quot; class=&quot;mw-redirect&quot; title=&quot;Kruskal Algorithm Implementation in C\C++&quot;&gt;Kruskal Algorithm Implementation in C\C++&lt;/a&gt; to &lt;a href=&quot;/wiki/Kruskal_Algorithm_Implementation_in_C/C%2B%2B&quot; title=&quot;Kruskal Algorithm Implementation in C/C++&quot;&gt;Kruskal Algorithm Implementation in C/C++&lt;/a&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&#039;vertical-align: top;&#039; lang=&#039;en&#039;&gt;
				&lt;td colspan=&#039;1&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&#039;1&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 21:01, 28 January 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&#039;2&#039; style=&#039;text-align: center;&#039; lang=&#039;en&#039;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Arjun Suresh</name></author>	</entry>

	<entry>
		<id>https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;diff=1991&amp;oldid=prev</id>
		<title>Arjun Suresh at 22:30, 18 December 2013</title>
		<link rel="alternate" type="text/html" href="https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;diff=1991&amp;oldid=prev"/>
				<updated>2013-12-18T22:30:28Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;tr style=&#039;vertical-align: top;&#039; lang=&#039;en&#039;&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 22:30, 18 December 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include&amp;lt;iostream&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include&amp;lt;iostream&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;using namespace std;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;using namespace std;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Arjun Suresh</name></author>	</entry>

	<entry>
		<id>https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;diff=1613&amp;oldid=prev</id>
		<title>Arjun Suresh at 21:49, 13 December 2013</title>
		<link rel="alternate" type="text/html" href="https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;diff=1613&amp;oldid=prev"/>
				<updated>2013-12-13T21:49:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;col class=&#039;diff-marker&#039; /&gt;
				&lt;col class=&#039;diff-content&#039; /&gt;
				&lt;tr style=&#039;vertical-align: top;&#039; lang=&#039;en&#039;&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&#039;2&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 21:49, 13 December 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l94&quot; &gt;Line 94:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 94:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; int ei = 0;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; int ei = 0;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; dsets disset;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; dsets disset;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; int c, d, i, u, fi=0, j, t;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; int c, d, i, u, fi = 0, j, t;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cout &amp;lt;&amp;lt; &amp;quot;Enter the edges and cost\n0 to stop:\n &amp;quot;;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cout &amp;lt;&amp;lt; &amp;quot;Enter the edges and cost\n0 to stop:\n &amp;quot;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	while(1)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	while(1)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Arjun Suresh</name></author>	</entry>

	<entry>
		<id>https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;diff=1612&amp;oldid=prev</id>
		<title>Arjun Suresh: Created page with &quot;&lt;syntaxhighlight lang=&quot;C&quot;&gt; #include&lt;iostream&gt;   using namespace std;  int vi=0; char vertex[20];  struct nod  {      char x;      struct nod *rep;      struct nod *next;  };  ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://gatecse.in/w/index.php?title=Kruskal_Algorithm_Implementation_in_C/C%2B%2B&amp;diff=1612&amp;oldid=prev"/>
				<updated>2013-12-13T21:48:45Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt; #include&amp;lt;iostream&amp;gt;   using namespace std;  int vi=0; char vertex[20];  struct nod  {      char x;      struct nod *rep;      struct nod *next;  };  ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#include&amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
int vi=0;&lt;br /&gt;
char vertex[20];&lt;br /&gt;
&lt;br /&gt;
struct nod&lt;br /&gt;
 {&lt;br /&gt;
     char x;&lt;br /&gt;
     struct nod *rep;&lt;br /&gt;
     struct nod *next;&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
struct list&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    nod node; &lt;br /&gt;
    struct nod *head;&lt;br /&gt;
    struct nod *tail;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class dsets&lt;br /&gt;
{&lt;br /&gt;
    list *s[20];&lt;br /&gt;
    int nlist;&lt;br /&gt;
public:&lt;br /&gt;
    dsets()&lt;br /&gt;
	{&lt;br /&gt;
	    nlist = 0;&lt;br /&gt;
	}&lt;br /&gt;
    void makeset(char a)&lt;br /&gt;
	{&lt;br /&gt;
	    s[nlist] = new list;&lt;br /&gt;
	    s[nlist]-&amp;gt;node.x = a;&lt;br /&gt;
	    s[nlist]-&amp;gt;head = s[nlist]-&amp;gt;tail = s[nlist]-&amp;gt;node.rep = &amp;amp;(s[nlist]-&amp;gt;node);&lt;br /&gt;
	    s[nlist++]-&amp;gt;node.next = NULL;&lt;br /&gt;
	}&lt;br /&gt;
	    &lt;br /&gt;
    &lt;br /&gt;
    list* findset(char a)&lt;br /&gt;
	{&lt;br /&gt;
	    int i;&lt;br /&gt;
	    nod *trav;&lt;br /&gt;
	    for(i = 0; i &amp;lt; nlist; i++)&lt;br /&gt;
	    {&lt;br /&gt;
		trav = s[i]-&amp;gt;head;&lt;br /&gt;
		while(trav != NULL)&lt;br /&gt;
		{&lt;br /&gt;
		    if(trav-&amp;gt;x == a)&lt;br /&gt;
			return s[i];&lt;br /&gt;
		    trav = trav-&amp;gt;next;&lt;br /&gt;
		}&lt;br /&gt;
	    }&lt;br /&gt;
	    return NULL;&lt;br /&gt;
	}&lt;br /&gt;
    list* unin(list *a,list *b)&lt;br /&gt;
	{&lt;br /&gt;
	    nod* trav = b-&amp;gt;head;&lt;br /&gt;
	    a-&amp;gt;tail-&amp;gt;next = b-&amp;gt;head;   &lt;br /&gt;
	    a-&amp;gt;tail = b-&amp;gt;tail;	    &lt;br /&gt;
	    while(trav != NULL)&lt;br /&gt;
	    {&lt;br /&gt;
		trav-&amp;gt;rep = a-&amp;gt;head;&lt;br /&gt;
		trav = trav-&amp;gt;next;&lt;br /&gt;
	    }&lt;br /&gt;
	    &lt;br /&gt;
	    b-&amp;gt;head = b-&amp;gt;tail = NULL;&lt;br /&gt;
	    return a;&lt;br /&gt;
	}&lt;br /&gt;
    void disp()&lt;br /&gt;
	{&lt;br /&gt;
	    nod *trav;&lt;br /&gt;
	    for(int i = 0; i &amp;lt; nlist; i++)&lt;br /&gt;
	    {&lt;br /&gt;
		trav = s[i]-&amp;gt;head;&lt;br /&gt;
		while(trav != NULL)&lt;br /&gt;
		{&lt;br /&gt;
		    cout &amp;lt;&amp;lt; trav-&amp;gt;x &amp;lt;&amp;lt; &amp;quot;\t&amp;quot;;&lt;br /&gt;
		    trav = trav-&amp;gt;next;&lt;br /&gt;
		}&lt;br /&gt;
		cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    char b, a, start;&lt;br /&gt;
    int forest[20];&lt;br /&gt;
    char edge [20][2];&lt;br /&gt;
    int cost[20];&lt;br /&gt;
    int ei = 0;&lt;br /&gt;
    dsets disset;&lt;br /&gt;
    int c, d, i, u, fi=0, j, t;&lt;br /&gt;
	cout &amp;lt;&amp;lt; &amp;quot;Enter the edges and cost\n0 to stop:\n &amp;quot;;&lt;br /&gt;
	while(1)&lt;br /&gt;
	{&lt;br /&gt;
		cin &amp;gt;&amp;gt; a;&lt;br /&gt;
		if(a == &amp;#039;0&amp;#039;)&lt;br /&gt;
		    break;&lt;br /&gt;
		edge[ei][0] = a;&lt;br /&gt;
	       &lt;br /&gt;
		cin &amp;gt;&amp;gt; b;&lt;br /&gt;
		edge[ei][1] = b;&lt;br /&gt;
		cin &amp;gt;&amp;gt; cost[ei++];&lt;br /&gt;
		c = 0, d = 0;&lt;br /&gt;
		for(i = 0; i &amp;lt; vi; i++)&lt;br /&gt;
		{&lt;br /&gt;
		    if(a == vertex[i])&lt;br /&gt;
		    {&lt;br /&gt;
			c++;&lt;br /&gt;
			&lt;br /&gt;
		    }&lt;br /&gt;
		    if(b == vertex[i])&lt;br /&gt;
		    {&lt;br /&gt;
			d++;&lt;br /&gt;
		    }&lt;br /&gt;
		}&lt;br /&gt;
		if(c == 0)&lt;br /&gt;
		{&lt;br /&gt;
		    vertex[vi++] = a;&lt;br /&gt;
		    &lt;br /&gt;
		}&lt;br /&gt;
		if(d == 0)&lt;br /&gt;
		{&lt;br /&gt;
		    vertex[vi++] = b;&lt;br /&gt;
		    &lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	for(i = 0;  &amp;lt; ei; i++)&lt;br /&gt;
	    for(j = 0; j &amp;lt; ei-i-1; j++)&lt;br /&gt;
		if(cost[j] &amp;gt; cost[j+1])&lt;br /&gt;
		{&lt;br /&gt;
		    t = cost[j];&lt;br /&gt;
		    cost[j] = cost[j+1];&lt;br /&gt;
		    cost[j+1] = t;&lt;br /&gt;
		    for(int k = 0; k &amp;lt; 2; k++)&lt;br /&gt;
		    {&lt;br /&gt;
			t = edge[j][k];&lt;br /&gt;
			edge[j][k] = edge[j+1][k];&lt;br /&gt;
			edge[j+1][k] = t;&lt;br /&gt;
		    }&lt;br /&gt;
		}&lt;br /&gt;
	for(i = 0; i &amp;lt; vi; i++)&lt;br /&gt;
	    disset.makeset(vertex[i]);&lt;br /&gt;
	for(i = 0; i &amp;lt; ei; i++)&lt;br /&gt;
	{&lt;br /&gt;
	    &lt;br /&gt;
	    if(disset.findset(edge[i][0]) != disset.findset(edge[i][1]))&lt;br /&gt;
	    {&lt;br /&gt;
		forest[fi++] = i;&lt;br /&gt;
		disset.unin(disset.findset(edge[i][0]),disset.findset(edge[i][1]));&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	cout &amp;lt;&amp;lt; &amp;quot;The minimum spanning tree of the entered graph is the one through the following edges\n&amp;quot;;&lt;br /&gt;
	for(i = 0; i &amp;lt; fi; i++)&lt;br /&gt;
	{&lt;br /&gt;
	    cout &amp;lt;&amp;lt; edge[forest[i]][0] &amp;lt;&amp;lt; &amp;quot;\t&amp;quot;&amp;lt;&amp;lt;edge[forest[i]][1] &amp;lt;&amp;lt; endl;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Template:FB}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;disqus/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Graphs]]&lt;/div&gt;</summary>
		<author><name>Arjun Suresh</name></author>	</entry>

	</feed>