迪杰斯特拉算法
伪代码
这里是引用
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<iostream>
#include<stdio.h>
using namespace std;
const int LEN = 7;
const int inf = INT_MAX;
int Graph[LEN][LEN] =
{ {-1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, 10, -1, 30, 100},
{-1, -1, -1, 5, -1, -1, -1},
{-1, -1, -1, -1, 50, -1, -1},
{-1, -1, -1, -1, -1, -1, 10},
{-1, -1, -1, -1, 20, -1, 60},
{-1, -1, -1, -1, -1, -1, -1} };
int crateGraph()
{
for (int i = 1; i < LEN; i++)
{
for (int j = 0; j < LEN; j++)
{
if (Graph[i][j] == -1)
Graph[i][j] = INT_MAX;
if(i == j)