Showing posts with label Single Source Shortest Path. Show all posts
Showing posts with label Single Source Shortest Path. Show all posts

Thursday, April 14, 2011

Single Source Shortest Path


import java.io.*;
class Graph
{   DataInputStream d=new DataInputStream(System.in);
                int e,v,g[][];
                void creategraph()throws IOException
                {
                                int a,b,i,j;int source,dest;
                                System.out.println("enter no of vertices");
                                v=Integer.parseInt(d.readLine());
                                System.out.println("enter no of edges");
                                e=Integer.parseInt(d.readLine());
                                g=new int[v+1][v+1];
                                for(i=1;i<=v;i++)
                                for(j=1;j<=v;j++)
                                g[i][j]=0;
                               
                                for(i=1;i<=e;i++)
                                {
                                                int w;
                                                System.out.println("enter two vertices of edge "+i);
                                                a=Integer.parseInt(d.readLine());