- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
分支限界法单源最短路径(Branch and bound method; single source; shortest path)
分支限界法单源最短路径(Branch and bound method; single source; shortest path)
#包含iostream
使用名称空间;
#定义最大9999 / /定义无穷大
/ *
*图类,用以存放有关图的所有信息
* /
类图
{
公共:
/ / ---------------------------
/ /参数int初始节点编号
/ / --------------------------
无效shorestpaths(int);
无效showdist();
graph();
私人:
int n;//图的节点个数
int * / /存放顶点的前驱节点沪指;
int * C;/ /存放图的邻接矩阵
int *区;/ /存放源点到各个顶点的距离
};
/ *
*节点
* /
类minheapnode
{
朋友图;
公共:
int返回我geti() {;}
无效的SETI(int II)
{
I = II;
}
getlength() { int返回长度;}
无效的规定长度(len)
{
长度=透镜;
}
私人:
int i;//顶点编号
int长度;/ /当前路长
};
/ *
*最小堆
* /
类minheap
{
朋友图;
公共:
minheap();
minheap(int);
DeleteMin(minheapnode )无效;
插入(minheapnode);
布尔outofbounds();
私人:
int的长度;
minheapnode *结;
};
图::graph()
{
int = 0;
int = 0;
cout “请输入图的节点个数:”;
CIN;
cout “请输入图的邻接矩阵:(无穷大请以9999代替)“ endl;
c =新int * n + 1 ];
距离=新国际[ n + 1 ];
沪指=新国际[ n + 1 ];
/ / ------------------------------
/ /初始化邻接矩阵
/ / ------------------------------
对于(WI = 0;WI = n;WI + +)
{
c =新的int [ n + 1 ];
如果(WI = 0)
{
因为(易= 0;易;
{
[易] = 0;
}
}
其他的
{
因为(易= 0;易;
{
如果(= = 0)
{
[易] = 0;
}
其他的
{
[易];
}
}
}
}
/ / ----------------------------------
/ /初始化数组
/ / ----------------------------------
对于(WI = 0;WI = n;WI + +)
{
[取消] =最大距离;
沪指[无线] = 0;
}
}
图:showdist()无效:
{
cout “从源点到该节点的最短路径:“ endl;
int = i 0;
int = 0;
对于(i = 1;i = n;i + +)
{
cout “dist [“我”] =“区[我] endl;
}
cout “从源点到终点的最短路径长度为:“ dist [N] endl;
cout “其路径为:”;
温度= n;
而(临时)!= 0)
{
如果(沪指[温度] = = 0)
{
cout (临时);
}
其他的
{
cout (临时)“”;
}
温度=沪指[温度];
}
cout endl;
}
图:ShorestPaths:无效(int V)
{
minheap h(n);/ /最小堆
minheapnode E;/ /扩展节点
E. = V;
e.length = 0;
距离[五] = 0;
/ /搜索问题的解空间树
虽然(真实)
{
int = 0;
对于(j=1;j=n;j + +)
{
cout “C [“即”] [“ J ”] =“ C [即] [ J ] endl;
如果((C [即] [ J ]!= max)和(C [即] [ J ]!= 0)
{
/ /节点控制关系
如果(e.length + C [即] [ J ] 区[ J ])
{
距离[ J ] = e.length + C [即] [ J ];
沪指[ J ] = E.;
/ /加入活结点优先队列
/ /若节点为叶子节点,则不加入活结点队列
如果(j)!= n)
{
minheapnode n;
n.i = J;
n.length =分布[J].;
H.Insert(N);
}
}
其他的
{
H.DeleteMin(E);
}
}
}
如果(H. outofbounds())
{
打破;
}
cout “上一个扩展节点”即” e.length endl;
H.DeleteMin(E);
您可能关注的文档
- 《水——生命之源》综合实践活动方案(Water - the source of life comprehensive practical program of activities).doc
- 《治病救人》(Saving lives).doc
- 《海阔天空》——唱响中国卡车司机之歌(China as boundless as the sea and sky truckers Song - sing).doc
- 《涉外警务概论》复习资料(Review information of introduction to foreign police affairs).doc
- 《液压与气动技术》五.综合题(Hydraulic and pneumatic technology, five).doc
- 《烧烤百科全书》大家出游一定要准备的烧烤材料(Barbecue encyclopedia, we must travel prepared barbecue materials).doc
- 《物理化学》课程教学大纲(Syllabus of Physical Chemistry).doc
- 《泰法战争》(Thai French war).doc
- 《物理学史》教学大纲(Syllabus for the history of Physics).doc
- 《特殊教育导论》(部分考核答案)01(Introduction to special education (part of the examination answer) 01).doc
- 分析中国音乐文化和音乐艺术概念(Analyzing the concepts of Chinese music culture and musical art).doc
- 分析化学进展(Advances in Analytical Chemistry).doc
- 分析我国进口石油运输布局与运输安全性(Analysis of the layout and transportation safety of China's imported petroleum).doc
- 出票细则(Detailed rules).doc
- 分析空气压缩机温度高的原因(Analyze the cause of high temperature of air compressor).doc
- 创业元老的安置模式探析(An analysis of the placement model of the old entrepreneurs).doc
- 分享男士72天减肥60斤的经验(Share the experience of 60 kg weight reduction for 72 days).doc
- 创业家杂志封面还我创业权(Entrepreneur Magazine Cover also my right to start business).doc
- 创业导师相关资料-摘抄(Business mentor - extract relevant information).doc
- 创业思路(Entrepreneurial thinking).doc
原创力文档


文档评论(0)