Add to Favorites    Make Home Page 4793 Online
 Language Categories
 Source Codes Home Project Ideas New! Interview Questions FAQs Home ASP Home ASP Source Codes ASP Script Directory New! ASP .Net Script Directory New! ASP Interview Questions ASP FAQs ASP How Tos C Home C Source Codes C Script Directory New! C Interview Questions C FAQs C How Tos C++ Home C++ Source Codes C++ Script Directory New! C++ Interview Questions C++ FAQs C++ How Tos Java Home Java Source Codes Java Directory New! Java Interview Questions Java FAQs Java How Tos JavaScript Home JavaScript Directory New! JavaScript Source Codes JavaScript FAQs JavaScript How Tos COBOL Home COBOL Source Codes COBOL FAQs COBOL How Tos Pascal Home Pascal Source Codes Pascal FAQs Pascal How Tos PHP Script Directory New! Python Script Directory New! Perl & CGI Script Directory New! Flash Script Directory New! CFML Script Directory New! Remotely Hosted Scripts New! Tools & Utilities Directory New! XML Script Directory New! Best Programmers Amit Mathur Vishal Bhardwaj Deepesh Jain Vyom NetWork
 Our Services

Home » C++ Home » Algorithms Home » Graphic Simulation for Shortest & 2nd shortest path in a Weighted Graph using Dijkstra's Algorithm.

A D V E R T I S E M E N T

Search Projects & Source Codes:

 Title Graphic Simulation for Shortest & 2nd shortest path in a Weighted Graph using Dijkstra's Algorithm. Author Abhishek .H. Dwivedi Author Email yarrows [at] indiatimes.com Description This program is used as a simulation for routing packets between routers. There are 2 subnets, one of whose weights will have to be entered by the user(positive only).The user will be asked for the source and destination nodes, for which he has a choice of 0 to 7 ONLY.(These are the numbers alotted to the nodes).The graphic part will show a green colored line drawn from the source to the destination, that indicates the shortest path. This is calculated by Dijkstra's algorithm. If one more packet is desired, a second shortest path is chosen to avoid traffic. This is indicated by the red colored path. Finally, the user enters source and dest for subnet 2(0 to 7 ONLY).The destination from 1st subnets forwards the packet to the source of 2nd subnet, and from there by the shortest path to the destnation of the 2nd subnet. Category C++ » Algorithms Hits 356403 Code Select and Copy the Code #include #include #include #include float sum=0,w=0,s,wn,v[8],td=0,e,i,j,n,w1[8],j1[8],arr[8],arr1[8],e1,count,d2,y1 ; float var,a[8][8],d[8],p[8],n1,c,c1,w2; void main() { int gd=DETECT,gm; clrscr(); void draw(float,float); void dijkstra(float s,float e,float v1[8],float d1[8],float p1[8],float a1[8][8],float n); void ssp(); void path(); void initial(); printf("There are 8 routers in each subnet "); n=8; for(i=0;ij1[v1]) { line(x,y,x,y-1); delay(10); y=y-1; } else { line(x,y,x,y+1); delay(10); y=y+1; }}} if(y==j1[v1]) { while(x!=w1[v1]) { if(x>w1[v1]) { line(x,y,x-1,y); delay(10); x=x-1; } else { line(x,y,x+1,y); delay(10); x=x+1; }}} if(xw1[v1]&&y>j1[v1]) { while(x!=w1[v1]) { line(x,y,x-1,y-s); delay(10); x=x-1; y=y-s; i=i+1; }} if(x>w1[v1]&&yj1[v1]) { while(x!=w1[v1]) { line(x,y,x+1,y-s); delay(10); x=x+1; y=y-s; i=i+1; } }} void ssp() { d2=y1=32767; setcolor(RED); e1=e; for(i=0;i

Related Source Codes

 Script Name Author Moving ball screen saver karlmarx The Classic Game of Snake & Ladder Lakshmi Narayana .A Railway seat reservation question which comes in sapient VyomWorld To calculate percentile Ravi Mathur Send to folder ANIMESH SAHU Analog clock and calendar Nazia & Rida HIGH/LOW GAME MOLLY ARORA Data structure (stack Implimentation) Swapnil B Adsure Memory Game AnirudhSanyal Easy Calc Anirudh Sanyal GK Quiz Anirudh Sanyal Hangman Game Manish Jain Snakeman Manish Jain Full month Calendar Nigi Cursor shapes nigi

A D V E R T I S E M E N T

Subscribe to SourceCodesWorld - Techies Talk
Email:

 Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home