1

I'm trying to get a faster pathfinding mechanism in place in a game I'm working on for a connected node graph. The nodes are classed into two types, "Networks" and "Routers."


In this picture, the blue circles represent routers and the grey rectangles networks.

Each network keeps a list of which routers it is connected to, and vice-versa. Routers cannot connect directly to other routers, and networks cannot connect directly to other networks.


Networks list which routers they're connected to



Routers do the same

I need to get an algorithm that will map out a path, measured in the number of networks crossed, for each possible source and destination network excluding paths where the source and destination are the same network. I have one right now, however it is unusably slow, taking about two seconds to map the paths, which becomes incredibly noticeable for all connected players.

The current algorithm is a depth-first brute-force search (It was thrown together in about an hour to just get the path caching working) which returns an array of networks in the order they are traversed, which explains why it's so slow. Are there any algorithms that are more efficient?

As a side note, while these example graphs have four networks, the in-practice graphs have 55 networks and about 20 routers in use. Paths which are not possible also can occur, and as well at any time the network/router graph topography can change, requiring the path cache to be rebuilt.

What approach/algorithm would likely provide the best results for this type of a graph?

4

2 回答 2

1

Dijkstra 的最短路径算法是经典的,但仅针对静态图设计。

您可以尝试在网上搜索动态最短过去算法。

这是一篇似乎相关的论文:http ://www.utdallas.edu/~edsha/papers/bin/Globecom04_SPT.pdf (可能会给你其他线索)。

本文描述了一个路由器网络,其中每个路由器都维护着自己的最短路径表。也许你可以做类似的事情。

我建议您通常也查看路由算法,因为采用最短路径总是可能导致拥塞等(我在想 16 队 Halo!)。您可能还想合并负载平衡等。

希望能帮助到你。

于 2010-06-02T01:50:14.093 回答
0

您可能想查看经典网络领域。这不是确切的答案,但应该为您提供“优于蛮力”算法的起点。

http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

于 2010-06-01T05:55:37.467 回答