动态规划:多段图最短路径

标签:
动态规划:多段图最短路径it |
分类: 数据结构&算法设计与分析 |
动态规划:多段图最短路径
cost[8]=C89+cost[9]=3
cost[7]=C79+cost[9]=7
cost[6]=min{C68+cost[8]}=8
cost[5]=min{C57+cost[7],C58+cost[8]}=9
cost[4]=min{C47+cost[7],C48+cost[8]}=9
cost[3]=min{C35+cost[5],C36+cost[6]}=13
cost[2]=min{C23+cost[3],C24+cost[4],C26+cost[6]}=14
cost[1]=min{C14+cost[4],C15+cost[5]}=17
cost[0]=min{C01+cost[1],C02+cost[2]}=15
path[0]=2
path[2]=3
path[3]=5
path[5]=8
path[8]=9
最短路径为:0-2-3-5-8-9
---以下代码使用的是Java语言(Java写的顺手了o(∩_∩)o...)