Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# generic graph search framework

Tags:

c#

search

graph

I have now coded up various graph search (A*, DFS, BFS, etc..) algorithms many times over. 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.

like image 510
captncraig Avatar asked Feb 26 '23 16:02

captncraig


2 Answers

Perhaps QuickGraph will be of interest.

QuickGraph provides generic directed/undirected graph datastructures and algorithms for .Net 2.0 and up. 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

like image 188
Scott Weinstein Avatar answered Feb 28 '23 07:02

Scott Weinstein


This sounds like a perfect use case for either a Delegate or a Lambda Expression.

Using Lambda Expressions for Tree Traversal – C#
http://blog.aggregatedintelligence.com/2010/05/using-lambda-expressions-for-tree.html

like image 42
Robert Harvey Avatar answered Feb 28 '23 05:02

Robert Harvey