2014-05-09 85 views
1

我有,每個環節都有如下計算成本的網絡:如何計算兩個非鄰居節點之間的總鏈路成本?

ask links [ set link-cost sum [node-cost] of both-ends ] 

如何計算不在鄰居兩個節點之間的總鏈路成本(鏈路成本的總和)?

to total-link-node [ a b ] ;; where a and b are nodes 
ask a [ 
print [link-cost] of (link-with b) ] 
end 

gives "OF expected input to be a link agentset or link but got NOBODY instead" 

在此先感謝您的幫助。

+0

我認爲你需要https://github.com/NetLogo/ NW-Extension爲此。希望有一個比我更瞭解的人會回答。 –

回答

3

下面是在擴展NW使用nw:path-to一個可能的解決方案由Seth的建議(也可以使用nw:weighted-path-to):

to total-link-node [a b] 
ask a [ 
    show nw:path-to b 
    print sum (map [ [link-cost] of ? ] nw:path-to b) ] 
end 
相關問題