在Java中表示图形的最佳方法是什么?我是这样做的:
tidydata <- reshape(data,varying =list(paste0("choice",1:3),
paste0("score",1:3)),direction="long",v.names=c("choice","score")) %>%
arrange(id) %>% filter(expert==choice)
我必须找到最短的路径,但似乎没有添加拱门,为什么?我也做了源和目标的设置和获取。但是我必须找到这个源和目标之间的最短路径,使用什么算法?我需要使用bfs来获取最短路径,但我的问题是如何遍历archs,我需要做一个递归函数我认为
答案 0 :(得分:0)
找到目标节点的最短路径的最佳算法是Iterative Deepening A*。
如果启发式值是可接受的,它会找到目标节点的最短路径,这意味着它不会高估。
这是伪代码:
$ puppet apply \
> --modulepath=/home/red/PUPPET/modules \
> --hiera_config=/home/red/PUPPET/hiera.yaml \
> -e 'include hello_world'
Notice: Compiled catalog for localhost in environment production in 0.07 seconds
Notice: /Stage[main]/Hello_world/Track_titles[/tmp/track-titles.txt]/ensure: created
Notice: Finished catalog run in 0.85 seconds
$ cat /tmp/track-titles.txt
one
two
three
g表示到达当前状态的移动次数,h表示到达目标状态的估计移动次数。 node current node
g the cost to reach current node
f estimated cost of the cheapest path (root..node..goal)
h(node) estimated cost of the cheapest path (node..goal)
cost(node, succ) step cost function
is_goal(node) goal test
successors(node) node expanding function, expand nodes ordered by g + h(node)
procedure ida_star(root)
bound := h(root)
loop
t := search(root, 0, bound)
if t = FOUND then return bound
if t = ∞ then return NOT_FOUND
bound := t
end loop
end procedure
function search(node, g, bound)
f := g + h(node)
if f > bound then return f
if is_goal(node) then return FOUND
min := ∞
for succ in successors(node) do
t := search(succ, g + cost(node, succ), bound)
if t = FOUND then return FOUND
if t < min then min := t
end for
return min
end function
。启发式值越接近实际移动次数,算法越快