我进行了一个寻路库。QuickGraph,开放式图形库,符合我的所有要求,但我遇到了一个问题。我需要最短路径算法来跳过当前移动代理无法通过的边缘。我想要的是这样的:
Func<SEquatableEdge<VectorD3>, double> cityDistances = delegate(SEquatableEdge<VectorD3> edge)
{
if(edge.IsPassableBy(agent))
return edgeWeight; // Edge is passable, return its weight
else
return -1; // Edge is impassable, return -1, which means, that path finder should skip it
};
Func<VectorD3, double> heuristic = ...;
TryFunc<VectorD3, IEnumerable<SEquatableEdge<VectorD3>>> tryGetPath = graph2.ShortestPathsAStar(cityDistances, heuristic, sourceCity);
我可以想象通过创建图形副本并删除无法通过的边来解决这个问题,但这对计算机资源来说是不必要的浪费。有人可以提示我如何解决这个问题吗?还是没有解决方案,我应该更新源?