开发者

Structure of Astar (A*) graph search data in C#

开发者 https://www.devze.com 2023-02-01 08:41 出处:网络
How do you structure you graphs/nodes 开发者_JAVA技巧in a graph search class? I\'m basically creating a NavMesh and need to generate the nodes from 1 polygon to the other. The edge that joins both pol

How do you structure you graphs/nodes 开发者_JAVA技巧in a graph search class? I'm basically creating a NavMesh and need to generate the nodes from 1 polygon to the other. The edge that joins both polygons will be the node.

Structure of Astar (A*) graph search data in C#

I'll then run A* on these Nodes to calculate the shortest path. I just need to know how to structure my classes and their properties?

I know for sure I wont need to create a fully blown undirected graph with nodes and edges.


All you need for A* is the ability to take a node and from it efficiently extract a list of its neighbouring nodes. If you already have some data structure that is keeping track of what edges are in what polygons then that seems straightforward; just write a function that takes an Edge and returns IEnumerable<Edge> by extracting that data out of your existing data structure.


Check out this series about the A* algorithm on Eric Lippert's blog. He explains, among other things, what data structures you need

0

精彩评论

暂无评论...
验证码 换一张
取 消