| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 394 人关注过本帖
标题:如何调用最短路径函数
只看楼主 加入收藏
zhailiqian
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-5-28
收藏
 问题点数:0 回复次数:0 
如何调用最短路径函数
如何调用这个函数啊?

Public Function shortpath(startno As Integer, endno As Integer) As Single
Dim result() As Single
Dim result1 As Integer
Dim s1 As Single
Dim min As Single
Dim ii, i, j, aa As Integer
Dim yc() As Boolean
Dim ycd() As Boolean
Dim rs1() As Single
Dim no() As Integer
Dim nopoint As Integer
ReDim yc(1 To maxno) As Boolean
ReDim ycd(1 To maxno) As Boolean
ReDim rs1(1 To maxno) As Single
ReDim result(1 To 2, 1 To maxno) As Single
For i = 1 To maxno
yc(i) = False
ycd(i) = False
rs1(i) = 1E+38
Next i
ll = startno
yc(ll) = True
j = 0
For aa = 1 To maxno
For i = 1 To indexa1(2, ll)
result1 = b1(indexa1(1, ll) - i + 1)
s1 = c1(indexa1(1, ll) - i + 1) + result(2, ll)
If yc(result1) = True Then GoTo 200
If ycd(result1) = True Then
If rs1(result1) >= s1 Then
rs1(result1) = s1
result(1, result1) = ll
result(2, result1) = s1
GoTo 200
Else
GoTo 200
End If
End If
ycd(result1) = True
rs1(result1) = s1
result(1, result1) = ll
result(2, result1) = s1
j = j + 1
ReDim Preserve no(1 To j) As Integer
no(j) = result1
200 Next i
For i = 1 To indexb2(2, ll)
result1 = a2(indexb2(1, ll) - i + 1)
s1 = c2(indexb2(1, ll) - i + 1) + result(2, ll)
If yc(result1) = True Then GoTo 300
If ycd(result1) = True Then
If rs1(result1) >= s1 Then
rs1(result1) = s1
result(1, result1) = ll
result(2, result1) = s1
GoTo 300
Else
GoTo 300
End If
End If
ycd(result1) = True
rs1(result1) = s1
result(1, result1) = ll
result(2, result1) = s1
j = j + 1
ReDim Preserve no(1 To j) As Integer
no(j) = result1
300 Next i
min = 1E+38
minpoint = Null
For i = aa To j
If min > rs1(no(i)) Then
ii = i
min = rs1(no(i))
minpoint = no(i)
End If
Next i
If min = 1E+38 Then Exit Function
no(ii) = no(aa)
no(aa) = minpoint
yc(minpoint) = True
ll = minpoint
If minpoint = endno Then Exit For
Next aa
Stpath = result(2, endno)
End Function

搜索更多相关主题的帖子: 函数 路径 
2007-05-28 10:25
快速回复:如何调用最短路径函数
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025434 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved