简体   繁体   English

C#通用图搜索框架

[英]C# generic graph search framework

I have now coded up various graph search (A*, DFS, BFS, etc..) algorithms many times over. 现在,我已经多次编码各种图形搜索(A *,DFS,BFS等)算法。 Every time, the only real difference is the actual search states I am searching over, and how new states are generated from existing ones. 每次,唯一的真正区别是我正在搜索的实际搜索状态,以及如何从现有状态中生成新状态。

I am now faced with yet another search-heavy project, and would like to avoid having to code and debug a general search algorithm again. 我现在面临着另一个繁重的搜索项目,并且希望避免再次编写代码和调试常规的搜索算法。 It would be really nice if I could define a search state class, including information for generating successive states, heuristic cost, etc, and just plug it in to some kind of existing search framework that can do all of the heavy lifting for me. 如果我可以定义一个搜索状态类,包括生成连续状态的信息,启发式成本等,然后将其插入某种可以为我完成所有繁重工作的现有搜索框架中,那将非常好。 I know the algorithms aren't particularly difficult to code, but there are always enough tricks involved to make it annoying. 我知道算法并不是特别难编码,但是总是有足够的技巧使它烦人。

Does anything like this exist? 像这样的东西存在吗? I couldn't find anything. 我什么都找不到。

Perhaps QuickGraph will be of interest. 也许QuickGraph会很有趣。

QuickGraph provides generic directed/undirected graph datastructures and algorithms for .Net 2.0 and up. QuickGraph为.Net 2.0及更高版本提供通用的有向/无向图数据结构和算法。 QuickGraph comes with algorithms such as depth first seach, breath first search, A* search, shortest path, k-shortest path, maximum flow, minimum spanning tree, least common ancestors, etc QuickGraph带有诸如深度优先搜索,呼吸优先搜索,A *搜索,最短路径,k最短路径,最大流量,最小生成树,最不常见祖先等算法。

This sounds like a perfect use case for either a Delegate or a Lambda Expression. 这听起来像是代表Lambda表达式的完美用例

Using Lambda Expressions for Tree Traversal – C# 使用Lambda表达式进行树遍历– C#
http://blog.aggregatedintelligence.com/2010/05/using-lambda-expressions-for-tree.html http://blog.aggregatedintelligence.com/2010/05/using-lambda-expressions-for-tree.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM