New to Telerik UI for WinFormsStart a free 30-day trial

Implements A* algorithm for finding the cheapest path between two points.

Definition

Namespace:Telerik.Windows.Diagrams.Core

Assembly:Telerik.WinControls.RadDiagram.dll

Syntax:

C#
public class AStarRouter : IExtendedRouter, IRouter

Inheritance: objectAStarRouter

Implements: IExtendedRouterIRouter

Constructors

Initializes a new instance of the AStarRouter class.

C#
public AStarRouter(IGraphInternal diagram)
Parameters:diagramIGraphInternal

The related diagram.

Properties

Gets or sets a value which indicates whether the routing algorithm tries to minimize connection overlaps. Default value is False.

C#
public bool AvoidConnectionOverlap { get; set; }

Gets or sets the avoid shapes property. This property determines if the routing will go around shapes or go through them.

C#
public bool AvoidShapes { get; set; }
Property Value:

The avoid shapes.

Gets or sets the distance around a segment in which an overlap is detected. Note: This property has effect only when AvoidConnectionOverlap is True. Default value is 3.

C#
public double SegmentOverlapDistance { get; set; }

Gets or sets the penalty value for a connection which overlaps another connection. Note: This property has effect only when AvoidConnectionOverlap is True. Default value is 0.75.

C#
public double SegmentOverlapPenalty { get; set; }

Gets or sets the penalty value for a connection which crosses a diagram shapes other than its start or end shape. Note: This property has effect only when AvoidShapes is True. Default value is 1.

C#
public double ShapeCrossPenalty { get; set; }

Gets or sets the penalty value for a connection which crosses its start or end shape. Default value is 3.

C#
public double StartOrEndShapeWallPenalty { get; set; }

Gets or sets the wall optimization.

C#
public bool WallOptimization { get; set; }
Property Value:

The wall optimization.

Methods

Calculates the bend alteration.

C#
protected virtual double CalculateBendAlteration(AStarNode node, AStarNode previousNode, Rect endWall, Point endPoint, Orientation currentOrientation, double penaltyBaseValue)
Parameters:nodeAStarNode

The node.

previousNodeAStarNode

The previous node.

endWallRect

The end wall.

endPointPoint

The end point.

currentOrientationOrientation

The current direction.

penaltyBaseValuedouble

The penalty base value.

Returns:

double

Calculates the wall penalty.

C#
protected virtual double CalculateWallPenalty(AStarNode node, double penaltyBaseValue)
Parameters:nodeAStarNode

The node.

penaltyBaseValuedouble

The penalty base value.

Returns:

double

Gets the route points.

C#
public IList<Point> GetRoutePoints(IConnection connection, bool showLastLine = true)
Parameters:connectionIConnection

The connection.

showLastLinebool

Whether the last line segment should be shown.

Returns:

IList<Point>

Implements: IRouter.GetRoutePoints(IConnection, bool)

Gets the route points and the start and end connectors.

C#
public ConnectionRoute GetRoutePoints(IConnection connection)
Parameters:connectionIConnection

The connection.

Returns:

ConnectionRoute

Implements: IExtendedRouter.GetRoutePoints(IConnection)

Calculates the sibling nodes.

C#
protected virtual IEnumerable<AStarNode> GetSiblingNodes(AStarNode node, Rect endWall, Point endPosition, Orientation preferredOrientation, double gridSize)
Parameters:nodeAStarNode

The node.

endWallRect

The end wall.

endPositionPoint

The end position.

preferredOrientationOrientation

The preferred direction.

gridSizedouble

Size of the grid.

Returns:

IEnumerable<AStarNode>