佛洛依德算法求最短路径实例
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
const int MAX_VALUE = 30;
int ShortestPathvalue[MAX_VALUE][MAX_VALUE] = {
0};
int ShortestPathmatrix[MAX_VALUE][MAX_VALUE] = {
0};
char _mapName[MAX_VALUE][50] = {
};
int _distance[MAX_VALUE][MAX_VALUE] = {
0};
typedef struct EdgeNode {
int adjvex;
int weight;
struct EdgeNode *next;
} edgeNode;
typedef struct VertexNode {
char data[50];
edgeNode *firstedge;
} VertexNode, AdjList[100];
typedef struct {
AdjList adjList;
int numVertexes, numEdges;
} GraphAdjList;
class AdjacencyList {
public:
void ShowALGraph(GraphAdjList *G);
void Test();
void InitMap(GraphAdjList *G);
void CreateALGraph(GraphAdjList *G);
void ShortestPath_Floyd(GraphAdjList *G, int P[MAX_VALUE][MAX_VALUE], int D[MAX_VALUE][MAX_VALUE]);
void ShowShortestResult(int originPos,int endPos);
};
void AdjacencyList::CreateALGraph(GraphAdjList *G) {
edgeNode *e;
for (int i = 0; i < G-