3 Answers, 1 is accepted
By default the AStarRouter has AvoidShapes property set to True. In your case, if you add the text as TextShapes - router will try to avoid them. You can try to disable this and test if it has positive impact on the performance. Generally the router has a lot of settings - via properties and via DiagramConstants class. Some of them (for example RoutinggridSize) can improve the performance but also there will be a quality loss.
Regarding labels, I would suggest you add them as Content of the connections or somehow integrated in the shapes or connectors instead of adding them as a shapes since this will make the routing algorithm slower.
Is there any way to set the maximum number of iterations for finding a path in AStarRouter? And, if the number of iterations exceeds the specified value, use another algorithm instead of AStarRouter, for example, InflatedRectRouter or edit settings of AStarRouter ( AvoidShapes for example)?
Also, do you have any ideas in the future to transfer the search for a path in AStarRouter to the background thread?
Now the main problem is in the diagram.Load(): this function is slow (if i use AStarRouter) and takes up the entire main thread, I cannot even provide the user with an animation of the load on the working field.
AStarRouter does not provide property for maximum iterations during a route finding traversal. It is an A* algorithm which uses heuristic function which adds possible weighted paths in a sorted queue. There is an internal function which indicates that a path is too long and does not add in in the queue (or adds it as failure, non-orthogonal path) and this plays the role of "cutting" the algorithm. Even if we make the this method protected there is no easy way to override it easily:
because H is previously computed distance :
Generally the property which speeds up the algorithm is DiagramConstants.RoutingGridSize which is actually the step (the step distance) which is added to every segment of a possible path. AvoidShapes - false and AvoidConnectionsverlap (false) might also speed up the performance in scenarios with too many shapes and connections in small viewport.
We haven't considered AsyncRoute kind of function before (or RoutingFinished event) (per connection or per diagram). You can submit a feature request in our feedback portal where we will review it, discuss it internally and eventually approve it.