使用 C# 进行图形导航
我有点困惑,试图想出一个好的算法来浏览下图。
替代文本 http://www.archimedesinc.biz/images/StackOverflow/Tree.jpg< /a>
如果用户选择“表 21”作为起点,我需要能够从该起始表获取到任何其他表的路径。
例如:如果用户选择“表 21”作为开始,然后添加“表 8”中的值,我需要创建以下路径“表 21 -> 表 12< /strong> -> 表 9 -> 表 6 -> 表 8”,表之间的所有权重为相同的。
我似乎忘记了处理有向图的技巧,想不出好的算法。 我并不是在寻求解决方案,只是在寻求正确的方向。
谢谢你!
I having a bit of a quandry trying to come up with a good algorithm to navigate the following graph.
alt text http://www.archimedesinc.biz/images/StackOverflow/Tree.jpg
If a user chooses "Table 21" as a starting point, I need to be able to get the path to any other table from that starting table.
EX: If the user chooses "Table 21" as a start and then adds a value from "Table 8", I need to create the following path "Table 21 -> Table 12 -> Table 9 -> Table 6 -> Table 8", all of the weights between the tables are the same.
I seem to have forgotten my skills in dealing with directed graphs, and can't think of a good algorithm. I'm not asking for a solution, but just a push in the right direction.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
广度优先搜索将找到最短路径: http://en.wikipedia.org/wiki/广度优先搜索
Breadth-first search will find a shortest path: http://en.wikipedia.org/wiki/Breadth-first_search
既然你说边的权重都相同,Dijkstra 算法(我通常的第一个这类事情的选择)只会降级为 广度优先搜索 所以我建议使用为了简单起见。
Since you said the edges are all of the same weight, Dijkstra's algorithm (my usual first choice for this sort of thing) will just degrade to breadth first search so I suggest using that for simplicity.
您可以从多种算法中进行选择来确定最短路径。 QuickGraph 擅长这类事情。
You can choose from a number of algorithms for determining the shortest path. QuickGraph is good at this sort of thing.