如何找到从s到t的路径长度& lt; = k与大多数'红色'节点? [英] How do I find path from s to t with length < = k with most 'red' nodes?

查看:79
本文介绍了如何找到从s到t的路径长度& lt; = k与大多数'红色'节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的算法有点生疏,所以也许你可以帮助我。

给出无向图(V,E)和数字K和假设一些顶点是'红色'而其他顶点是'蓝色'。

我怎样才能找到一条长度为< = K从s到t的路径通过最红的顶点?



谢谢



我尝试过:



i尝试寻找长度为1,而不是2的路径,......直到K但它仍然没有经过最大量的红色顶点。

Hi guys,
im a little rusty on my algorithms so maybe you can help me.
given an undirected graph (V,E) and a number K and suppose some of the vertices are 'red' and the others are 'blue'.
how can i find a path with length <= K from s to t that passes the most red vertices?

thanks

What I have tried:

i tried looking for a path with length 1, than 2, ... till K but it still doesnt go through the maximal amount of red vertices.

推荐答案

Quote:

如何找到一条长度为< = K的路径,从s到t传递最红的顶点?

how can i find a path with length <= K from s to t that passes the most red vertices?

解决方案很强大。

您必须逐个尝试所有可能的路径并保存到目前为止的最佳答案。

The solution is brut force.
You have to try all possible path one by one and save the best answer so far.


这篇关于如何找到从s到t的路径长度&amp; lt; = k与大多数'红色'节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆