123 Eng

### Engineering the engineers™

Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

Computer Science / IT
Electronics
Electrical
Mechanical
Chemical
Civil

CAT / MBA

GMAT / Foreign MBA
Latest Jobs

Displaying  Source Code(s)

 Graphic Simulation for Shortest & 2nd shortest path in a Weighted Graph using Dijkstra's Algorithm. -------------------------------------------------------------------------------- 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. #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

Contribute content or training reports / feedback / Comments
job placement papers