<?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>Shortest path | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/shortest-path/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 17:09:21 +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++ program to solve the single source shortest path problem Using Dijkstra’s algorithm</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-solve-the-single-source-shortest-path-problem-using-dijkstra%e2%80%99s-algorithm/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-solve-the-single-source-shortest-path-problem-using-dijkstra%e2%80%99s-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 11 Mar 2010 17:09:21 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[Shortest path]]></category>
		<category><![CDATA[Dijkstra’s algorithm]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1026</guid>

					<description><![CDATA[<p>/* Write a C++ program to solve the single source shortest path problem using Dijkstra’s algorithm */ #include #include #include using namespace std; int shortest(int ,int); int cost[10][10],dist[20],i,j,n,k,m,S[20],v,totcost,path[20],p; main() { int 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-program-to-solve-the-single-source-shortest-path-problem-using-dijkstra%e2%80%99s-algorithm/">C++ program to solve the single source shortest path problem Using Dijkstra’s algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write a C++ program to solve the single source shortest path problem using Dijkstra’s algorithm */</p>
<pre lang="cpp">
#include<iostream>
#include<conio.h>
#include<stdio.h>
using namespace std;
int shortest(int ,int);
int cost[10][10],dist[20],i,j,n,k,m,S[20],v,totcost,path[20],p;
main()
{
int c;
cout <<"enter no of vertices";
cin >> n;
cout <<"enter no of edges"; 
cin >>m;
cout <<"\nenter\nEDGE 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 <<"enter initial vertex";
cin >>v;
cout << v<<"\n";
shortest(v,n);
 }

int shortest(int v,int n)
{
int min;
for(i=1;i<=n;i++)
{
S[i]=0;
dist[i]=cost[v][i];
}
path[++p]=v;
S[v]=1;
dist[v]=0;
for(i=2;i<=n-1;i++)
{
k=-1;
min=31999;
for(j=1;j<=n;j++)
{
if(dist[j]<min &#038;&#038; S[j]!=1)
{
min=dist[j];
k=j;
} 
}
if(cost[v][k]<=dist[k])
p=1;
path[++p]=k;
for(j=1;j<=p;j++)
cout<<path[j];
cout <<"\n";
//cout <<k;
S[k]=1;
for(j=1;j<=n;j++)
if(cost[k][j]!=31999 &#038;&#038; dist[j]>=dist[k]+cost[k][j] && S[j]!=1)
 dist[j]=dist[k]+cost[k][j];
}
}
</pre>
<p><strong>OUTPUT</strong></p>
<p>enter no of vertices6<br />
enter no of edges11</p>
<p>enter<br />
EDGE Cost<br />
1 2 50<br />
1 3 45<br />
1 4 10<br />
2 3 10<br />
2 4 15<br />
3 5 30<br />
4 1 10<br />
4 5 15<br />
5 2 20<br />
5 3 35<br />
6 5 3<br />
enter initial vertex1<br />
1<br />
14<br />
145<br />
1452<br />
13</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-solve-the-single-source-shortest-path-problem-using-dijkstra%e2%80%99s-algorithm/">C++ program to solve the single source shortest path problem Using Dijkstra’s algorithm</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-program-to-solve-the-single-source-shortest-path-problem-using-dijkstra%e2%80%99s-algorithm/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
		<item>
		<title>C program to find the Shortest path for a given graph</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/c-program-to-find-the-shortest-path-for-a-given-graph/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/c-program-to-find-the-shortest-path-for-a-given-graph/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Sun, 20 Sep 2009 06:51:07 +0000</pubDate>
				<category><![CDATA[C Programs]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[Shortest path]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=791</guid>

					<description><![CDATA[<p>OUTPUT:<br />
enter the cost matrix :<br />
0 1 4 2 0<br />
0 0 0 2 3<br />
0 0 0 3 0<br />
0 0 0 0 5<br />
0 0 0 0 0<br />
enter number of paths : 4<br />
enter possible paths :<br />
1 2 4 5 0<br />
1 2 5 0 0<br />
1 4 5 0 0<br />
1 3 4 5 0<br />
minimum cost : 4<br />
minimum cost path :<br />
  1-->2-->5</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-program-to-find-the-shortest-path-for-a-given-graph/">C program to find the Shortest path for a given graph</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>OUTPUT:<br />
enter the cost matrix :<br />
0 1 4 2 0<br />
0 0 0 2 3<br />
0 0 0 3 0<br />
0 0 0 0 5<br />
0 0 0 0 0<br />
enter number of paths : 4<br />
enter possible paths :<br />
1 2 4 5 0<br />
1 2 5 0 0<br />
1 4 5 0 0<br />
1 3 4 5 0<br />
minimum cost : 4<br />
minimum cost path :<br />
  1&#8211;>2&#8211;>5</p>
<pre lang="c" escaped="true" line="1">
#include<stdio.h>
#include<conio.h>
void main()
{
int path[5][5],i,j,min,a[5][5],p,st=1,ed=5,stp,edp,t[5],index;
clrscr();
printf("enter the cost matrix\n");
for(i=1;i<=5;i++)
for(j=1;j<=5;j++)
scanf("%d",&#038;a[i][j]);
printf("enter  number of paths\n");
scanf("%d",&#038;p);
printf("enter possible paths\n");
for(i=1;i<=p;i++)
for(j=1;j<=5;j++)
scanf("%d",&#038;path[i][j]);
for(i=1;i<=p;i++)
{
t[i]=0;
stp=st;
for(j=1;j<=5;j++)
{
edp=path[i][j+1];
t[i]=t[i]+a[stp][edp];
if(edp==ed)
break;
else
stp=edp;
}
}
min=t[st];index=st;
for(i=1;i<=p;i++)
{
if(min>t[i])
{
min=t[i];
index=i;
}
}
printf("minimum cost %d",min);
printf("\n minimum cost path ");
for(i=1;i<=5;i++)
{
printf("--> %d",path[index][i]);
if(path[index][i]==ed)
break;
}
getch();
}
</pre>
<p>OUTPUT:<br />
enter the cost matrix :<br />
0 1 4 2 0<br />
0 0 0 2 3<br />
0 0 0 3 0<br />
0 0 0 0 5<br />
0 0 0 0 0<br />
enter number of paths : 4<br />
enter possible paths :<br />
1 2 4 5 0<br />
1 2 5 0 0<br />
1 4 5 0 0<br />
1 3 4 5 0<br />
minimum cost : 4<br />
minimum cost path :<br />
  1&#8211;>2&#8211;>5</p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/c-program-to-find-the-shortest-path-for-a-given-graph/">C program to find the Shortest path for a given graph</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/c-program-to-find-the-shortest-path-for-a-given-graph/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
			</item>
	</channel>
</rss>
