Showing posts with label All Pair Shortest Path. Show all posts
Showing posts with label All Pair Shortest Path. Show all posts

Thursday, April 14, 2011

All Pair Shortest Path


import java.io.*;
import java.util.*;
class graph
{
        int g[][],v,e,i,j,k;
        void creatgraph()
        {
                        Scanner s=new Scanner(System.in);
                        int a,b,w;
                        System.out.println("Enter no of vertices");
                        v=s.nextInt();
                        System.out.println("Enter no of edges");
                        e=s.nextInt();
                        g=new int[v+1][v+1];
                        for(int i=1;i<=v;i++)
                        for(int j=1;j<=v;j++)
        g[i][j]=32767;
        for(int i=1;i<=v;i++)
        g[i][i]=0;
                        for(int i=1;i<=e;i++)
                        {
                                        System.out.println("Enter edge information:");
                                        a=s.nextInt();
                                        b=s.nextInt();