PathfinderAI is a C# library with a programmatic approach to graph-based operations.
The supported platforms are .NET/.NET Core, .NET Framework 4.8+.
$ dotnet add package PathfinderAI
In this example we are creating a graph of airports.
- The graph takes a generic parameter for the node data which is user-defined (Airport).
- The graph can be populated manually via method chaining or through reading a .json file.
- Find desired nodes through lambda expressions and connect them with others via method chaining.
- Use the built-in pathfinding algorithms to traverse the graph.
public void InitializeGraph()
{
var Graph = new Graph<Airport>();
string graphDataPath = "Path/GraphData.json";
Graph.ReadFromJson(graphDataPath);
var sarajevo = Graph.GetNode(x => x.City == "Sarajevo");
var belgrade = Graph.GetNode(x => x.City == "Belgrade");
var zagreb = Graph.GetNode(x => x.City == "Zagreb");
var rome = Graph.GetNode(x => x.City == "Rome");
zagreb.AddNeighbor(rome, 44);
sarajevo.AddNeighbor(zagreb, 25).AddNeighborReverse(belgrade, 23);
var path = Graph.GetShortestPath(belgrade, rome, EnumHelper.Algorithms.DepthFirstSearch);
}
Pull requests are more than welcome, this is my first library project and any form of feedback is welcome.
For major changes, please open an issue first to discuss what you would like to change.