#include<iostream>
using namespace std;
struct graph
{
 int V;
 int E;
 int **adj;
};
graph* create()
{
 int u,v,i;
 graph *temp=new graph;
 cout<<"Enter total numbers of Vertex : ";
 cin>>temp->V;
 cout<<"Enter total number of edges : ";
 cin>>temp->E;
 int **arr=new int*[temp->V];
 for (i=0; i<temp->V; i++)
 {
  arr[i]=new int[temp->V];
 }
 temp->adj=arr;
 cout<<"enter the values on each verices :n";
 for(u=0; u<temp->V;u++)
 {
  for(v=0; v<temp->V; v++)
  {
   cout<<"write the distance between vertex "<<u<<" and "<<v<<" : ";
   cin>>temp->adj[u][v];
  }
 }
 return temp;
 
}
void show(graph *ptr)
{
 int i,j;
 graph *temp=ptr;
 cout<<"atbtctdn";
 for(i=0; i<temp->V;i++)
 {
  for(j=0;j<temp->V;j++)
  {
   cout<<temp->adj[i][j]<<"t";
  }
  cout<<"n";
 }
}
void floydwarshall(graph *ptr)
{
 int i,j,k;
 for(k=0; k<ptr->V;k++)
 {
  for(i=0; i<ptr->V; i++)
  {
   for(j=0;j<ptr->V; j++)
   {
    if(ptr->adj[i][k]+ptr->adj[k][j]<ptr->adj[i][j])
    {
     ptr->adj[i][j]=ptr->adj[i][k]+ptr->adj[k][j];
    }
   }
  }
 }

}
int main()
{
 graph *ptr=NULL;
 ptr=create();
 show(ptr);
 cout<<"Shortest Distance Between Paths n";
 floydwarshall(ptr);
 show(ptr); 
 return 0;
 
}