/*
It can be compiled in Visual C++.Net, Visual C++ 6.0 devcpp 4.9.5.0
The input format is of the following
The first line consists of two integers, indicating the number of vertices(V), and the number of edges(E)
It is followed by E lines, each line consists of 3 values, first two of which is the name of vertices that is linked (assuming using int type)
the third one is the weight of it
Note that the name of the vertices are from 0 on, but not 1
for example:
for a triangle, there are 3 vertices and 3 edges
you need to input as the following:
Please input the number of vertex: 3
Please input the number of edges: 3
Then you will have to input each edges' information,
one possible input:
please input the 1th edge's information: 0 1 5
please input the 2th edge's information: 1 2 1
please input the 3th edge's information: 2 0 2
it means that it will construct a triangle, with vertices denoted 0, 1, 2
the distance(weight) between 0, 1 is 5
the ... 1, 2 is 1
so the forth
the output of the adjacency link follows:
0->1->2->NULL
1->0->2->NULL
2->0->1->NULL
it indicates that 0 is linked to 1 and 2 (so the forth)
then you can input the 2 vertices' distance you want, take 0, 1 as instance:
Plz input 2 vertices(vertex1 vertex2), -1 indicates terminte: 0 1
Since the shortest path from 0 to 1 is 0->2->1 which is 3
the output will be 3.00000
*/
/*Firstly a matrix is constructed to store the input value. The convert them into linkList type
Note that I use to algorithm of All-Pair=Shortest-Path, which do not need the linkList*/
#include <stdio.h>
#include <stdlib.h>
#define INFINITE 100000000
struct Vertex_T
{
int vertexName;
double weight;
Vertex_T* next;
};
//typedef Vertex_T* Vertex;
int main()
{
int numVer = 0;
int numEdg = 0;
int i = 0;
int j = 0;
printf("Please input the number of vertex: ");
scanf("%d", &numVer);
printf("Please input the number of edges: ");
scanf("%d", &numEdg);
/*allocate the adjacency matrix*/
double** Matrix = NULL;
/*After all, I hope this will set an good example for you but not make you be lazier in the future.
Hopefully there won't be another guy that help you to write such a program*/