Dijkstra和Floyd求最短路径
记录一下这两个算法 Dijkstra # include <stdlib.h> # include <stdio.h> # include <iostream> using namespace std ; /*邻接矩阵法*/ # define MAXV 50 # define INF 32767 typedef struct { int edges [ MAXV ] [ MAXV ] ; int n , e ; } MatGraph ; void CreateGraph ( MatGraph & G ) //创建的是带权有向图 { int n , e ; int x , y , w ; printf ( "输入顶点和边的个数:\n" ) ; cin >> n >> e ; G . e = e ; G . n = n ; for ( int i = 0 ; i < G . n ; i ++ ) for ( int j = 0 ; j < G . n ; j ++ ) { if ( i == j ) G . edges [ i ] [ j ] = 0 ; else G . edges [ i ] [ j ] = INF ; } for ( int i = 0 ; i < G . e ; i ++ ) { printf ( "输入第%d条边的信息\n" , i + 1 ) ; cin >