Netlogo 如何计算两个非相邻节点之间的总链路成本?

Netlogo 如何计算两个非相邻节点之间的总链路成本?,netlogo,Netlogo,我有一个网络,其中每个链路的成本计算如下: 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 li

我有一个网络,其中每个链路的成本计算如下:

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"

提前感谢您的帮助。

下面是一个可能的解决方案,按照Seth的建议,在扩展名nw中使用
nw:path to
(您也可以使用
nw:weighted path to
):


下面是一个可能的解决方案,按照Seth的建议,在扩展名nw中使用
nw:path to
(您也可以使用
nw:weightedpath 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