博客
关于我
手撕最短路径——Dijkstra算法模板(c++最简单)
阅读量:199 次
发布时间:2019-02-28

本文共 611 字,大约阅读时间需要 2 分钟。

最短路径——Dijkstra算法模板

//最短路径——Dijstral算法 /*5 70 1 101 2 500 4 1000 3 302 4 103 4 603 2 20*/#include 
#include
#include
using namespace std;int Graph[100][100];int dist[100];int ver_num,edge_num;void CreateGraph(){ for(int i=0;i
>ver1>>ver2>>weight; Graph[ver1][ver2]=weight; }} int FindMinPos(){ int min_pos=0; for(int i=1;i
dist[i]&&dist[i]!=0) min_pos=i; } cout<<"0->"<
<<" "<
<
>ver_num>>edge_num; //memset(Graph,10000,sizeof(Graph)); for(int i=0;i

【测试数据】

5 7
0 1 10
1 2 50
0 4 100
0 3 30
2 4 10
3 4 60
3 2 20
【输出数据】
在这里插入图片描述

转载地址:http://ynbs.baihongyu.com/

你可能感兴趣的文章
NIH发布包含10600张CT图像数据库 为AI算法测试铺路
查看>>
Nim教程【十二】
查看>>
Nim游戏
查看>>
NIO ByteBuffer实现原理
查看>>
Nio ByteBuffer组件读写指针切换原理与常用方法
查看>>
NIO Selector实现原理
查看>>
nio 中channel和buffer的基本使用
查看>>
NIO_通道之间传输数据
查看>>
NIO三大组件基础知识
查看>>
NIO与零拷贝和AIO
查看>>
NIO同步网络编程
查看>>
NIO基于UDP协议的网络编程
查看>>
NIO笔记---上
查看>>
Vue3.0中的响应式原理(第九课)
查看>>
NIO蔚来 面试——IP地址你了解多少?
查看>>
NISP一级,NISP二级报考说明,零基础入门到精通,收藏这篇就够了
查看>>
NISP国家信息安全水平考试,收藏这一篇就够了
查看>>
NIS服务器的配置过程
查看>>
NIS认证管理域中的用户
查看>>
Nitrux 3.8 发布!性能全面提升,带来非凡体验
查看>>