【算法导论】24.3 Dijkstra算法

博客详细介绍了《算法导论》24.3章节中的Dijkstra算法,并提供了相应的C++代码实现。
摘要由CSDN通过智能技术生成

算法导论24.3章中算法的C++实现,代码如下:

/******************************************************************** 
* Copyright (C) 2012 Li Yachao 
* Contact: liyc7711(at)gmail.com 
* 
* Permission to use, copy, modify, and distribute this software for 
* any non-commercial purpose is hereby granted without fee, provided 
* that the above copyright notice appear in all copies and that both 
* that copyright notice.  
* It is provided "as is" without express or implied warranty.  
*********************************************************************/ 
#include <iostream>
using namespace std;

#define  N 5  /*顶点的数目*/
#define INFINITE 0x7fffffff

//顶点结点结构  
struct Vertex  
{  
	Vertex * next;/*指向下一个顶点*/
	int id;/*节点的标志*/
	int weight;/*节点的权值,临界表表头到此元素上边的权值*/
    Vertex():next(NULL),id(0){}  
};  

//图结构
struct Graph
{
	Vertex *Adj[N+1];//N个顶点及邻接点头指针
	int p[N&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值