求解網絡中的最短路徑。假設某個計算機網絡有n個站點,依次編號為1,2,…,n;有的站點之間有直接的線路連接(即這兩個站點之間沒有其它站點),有的站點之間沒有直接的線路連接。如果用三元組(i,j,f)來表示該網絡中的站點I和站點j之間有直接的線路連接且它們之間的距離為f 當已知該網絡各站點之間的直接連接情況由m個三元組(i1,j1,f1),(i2,j2,f2),…,(im,jm,fm)確定時,要求計算出對于網絡中任意一個站點g(1≤g≤n)到其余各站點的最短距離。
標簽:
網絡
最短路徑
站點
計算機網絡
上傳時間:
2013-12-27
上傳用戶:asdkin
prolog 找路例子程序:
=== === === === === ===
Part 1-Adding connections
Part 2-Simple Path
example
| ?- path1(a,b,P,T).
will produce the response:
T = 15
P = [a,b] ?
Part 3 - Non-repeating path
As an example, the query:
?- path2(a,h,P,T).
will succeed and may produce the bindings:
P = [a,depot,b,d,e,f,h]
T = 155
Part 4 - Generating a path below a cost threshold
As an example, the query:
?- path_below_cost(a,[a,b,c,d,e,f,g,h],RS,300).
returns:
RS = [a,b,depot,c,d,e,g,f,h] ?
RS = [a,c,depot,b,d,e,g,f,h] ?
no
==================================
標簽:
Part
connections
example
prolog
上傳時間:
2015-04-24
上傳用戶:ljt101007