Class AdaptiveGraphRouting
Class for routing through an AdaptiveGrid.
Inheritance
Inherited Members
Namespace: Elements.Spatial.AdaptiveGrid
Assembly: Hypar.Elements.dll
Syntax
public class AdaptiveGraphRouting
Constructors
AdaptiveGraphRouting(AdaptiveGrid, RoutingConfiguration)
Create AdaptiveGraphRouting objects and store core parameters for further use.
Declaration
public AdaptiveGraphRouting(AdaptiveGrid grid, RoutingConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
AdaptiveGrid | grid | AdaptiveGrid the algorithm travels through. |
RoutingConfiguration | configuration | Storage for common parameters that affect routing. |
Fields
ErrorMessages
List of error messages that occur during routing. Are reset on the beginning of each routing operation.
Declaration
public List<Message> ErrorMessages
Field Value
Type | Description |
---|---|
System.Collections.Generic.List<Message> |
Methods
AddPlanarWeightModifier(String, Plane, Double, String)
Create WeightModifier that sets the factor on all edges lying on a given plane.
Declaration
public WeightModifier AddPlanarWeightModifier(string name, Plane plane, double factor, string group = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of new WeightModifier. |
Plane | plane | Plane to check if edge lays on. |
System.Double | factor | Factor of new WeightModifier. |
System.String | group | Group name of new WeightModifier. |
Returns
Type | Description |
---|---|
WeightModifier | Created WeightModifier. |
AddPolylineWeightModifier(String, Polyline, Double, Double, Boolean, String)
Create WeightModifier that sets the factor on all edges parallel(both points must be withing influence radius of the polyline) or intersecting with given polyline.
Declaration
public WeightModifier AddPolylineWeightModifier(string name, Polyline polyline, double factor, double influenceDistance, bool is2D, string group = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of new WeightModifier. |
Polyline | polyline | Polyline to check if edge is affected or intersected. |
System.Double | factor | Factor of new WeightModifier. |
System.Double | influenceDistance | Influence radius of polyline. |
System.Boolean | is2D | Whether edge and polyline comparison should be considered in 2d or 3d. |
System.String | group | Group name of new WeightModifier. |
Returns
Type | Description |
---|---|
WeightModifier | Created WeightModifier. |
AddRoutingFilter(AdaptiveGraphRouting.RoutingFilter)
Routing supports checking if a Vertex can be added to the path. New vertex must pass all filter functions to be accepted.
Declaration
public void AddRoutingFilter(AdaptiveGraphRouting.RoutingFilter f)
Parameters
Type | Name | Description |
---|---|---|
AdaptiveGraphRouting.RoutingFilter | f | New filter function. |
AddWeightModifier(WeightModifier)
Add WeightModifier to the dictionary of modifiers.
Declaration
public void AddWeightModifier(WeightModifier modifier)
Parameters
Type | Name | Description |
---|---|---|
WeightModifier | modifier | WeightModifier to add. |
AggregateFactorMax(Double, Double)
Return maximum of factors.
Declaration
public static double AggregateFactorMax(double a, double b)
Parameters
Type | Name | Description |
---|---|---|
System.Double | a | First factor. |
System.Double | b | Second factor. |
Returns
Type | Description |
---|---|
System.Double | Maximum of factors. |
AggregateFactorMin(Double, Double)
Return minimum of factors.
Declaration
public static double AggregateFactorMin(double a, double b)
Parameters
Type | Name | Description |
---|---|---|
System.Double | a | First factor. |
System.Double | b | Second factor. |
Returns
Type | Description |
---|---|
System.Double | Minimum of factors. |
AggregateFactorMultiply(Double, Double)
Multiply factors.
Declaration
public static double AggregateFactorMultiply(double a, double b)
Parameters
Type | Name | Description |
---|---|---|
System.Double | a | First factor. |
System.Double | b | Second factor. |
Returns
Type | Description |
---|---|
System.Double | Result of multiplication of factors. |
BuildSimpleNetwork(IList<RoutingVertex>, IList<UInt64>, IEnumerable<RoutingHintLine>)
Create network of routes between set of input Vertices and set of exit Vertices. Each route is most efficient individually, without considering other routes. Each route is connected to the network using Dijkstra algorithm.
Declaration
public IDictionary<ulong, TreeNode> BuildSimpleNetwork(IList<RoutingVertex> leafVertices, IList<ulong> exits, IEnumerable<RoutingHintLine> hintLines = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<RoutingVertex> | leafVertices | Vertices to connect into the system with extra information attached. |
System.Collections.Generic.IList<System.UInt64> | exits | Possible exit vertices. |
System.Collections.Generic.IEnumerable<RoutingHintLine> | hintLines | Collection of lines that routes are attracted to. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.UInt64, TreeNode> | Travel tree from inputVertices to one of the exits. |
BuildSpanningTree(IList<RoutingVertex>, UInt64, IEnumerable<RoutingHintLine>, TreeOrder)
Creates tree of routes between set of input Vertices and the exit Vertex. Routes merge together to form a single trunk. Starting from end, point by point, vertices are connected to the network using Dijkstra algorithm.
Declaration
public IDictionary<ulong, TreeNode> BuildSpanningTree(IList<RoutingVertex> leafVertices, ulong trunkVertex, IEnumerable<RoutingHintLine> hintLines, TreeOrder order)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<RoutingVertex> | leafVertices | Vertices to connect into the system with extra information attached. |
System.UInt64 | trunkVertex | End vertex id. |
System.Collections.Generic.IEnumerable<RoutingHintLine> | hintLines | Collection of lines that routes are attracted to. At least one hint line is required. |
TreeOrder | order | In which order tree is constructed |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.UInt64, TreeNode> | Travel tree from inputVertices to the trunkVertex. |
BuildSpanningTree(IList<List<RoutingVertex>>, UInt64, IList<List<RoutingHintLine>>, TreeOrder)
Creates tree of routes between multiple sections, each having a set of input Vertices, hint lines and local end Vertex, and the exit Vertex. Route is created by using Dijkstra algorithm locally on different segments. Segments are merged together to form a single trunk. Starting from end, point by point, segments are connected. Then, Vertices in each segments are connected as well, forming a local trunk, connected with the main one. All parameter except "trunkPathVertices" are provided per section in the same order.
Declaration
public IDictionary<ulong, TreeNode> BuildSpanningTree(IList<List<RoutingVertex>> leafVertices, ulong trunkVertex, IList<List<RoutingHintLine>> hintLines, TreeOrder order)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<System.Collections.Generic.List<RoutingVertex>> | leafVertices | Vertices to connect into the system with extra information attached. |
System.UInt64 | trunkVertex | End vertex id. |
System.Collections.Generic.IList<System.Collections.Generic.List<RoutingHintLine>> | hintLines | Collection of lines that routes are attracted to. At least one hint line per group is required. |
TreeOrder | order | In which order tree is constructed |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.UInt64, TreeNode> | Travel tree from inputVertices to the trunkVertex. |
ClearWeightModifiers()
Remove all WeightModifier from the dictionary of modifiers.
Declaration
public void ClearWeightModifiers()
GetWeightModifier(String)
Get WeightModifier with given name.
Declaration
public WeightModifier GetWeightModifier(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of WeightModifier. |
Returns
Type | Description |
---|---|
WeightModifier | WeightModifier object. |
GetWeightModifiersGroup(String)
Get list of WeightModifier with specified group name.
Declaration
public List<WeightModifier> GetWeightModifiersGroup(string groupName)
Parameters
Type | Name | Description |
---|---|---|
System.String | groupName | Group name. Must be not null. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<WeightModifier> | List of WeightModifier with the specified group name. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Throws if |
RemoveWeightModifier(WeightModifier)
Remove WeightModifier from the dictionary of modifiers.
Declaration
public bool RemoveWeightModifier(WeightModifier modifier)
Parameters
Type | Name | Description |
---|---|---|
WeightModifier | modifier | WeightModifier to remove. |
Returns
Type | Description |
---|---|
System.Boolean | False if WeightModifier is not present in the dictionary of modifiers. |
RenderElements(IList<RoutingHintLine>, IList<Vector3>)
Visualize adaptive graph edges. Material depends on elevation and proximity to different hint lines. Original split points are not stored in the graph, so they need to be provided.
Declaration
public IList<Element> RenderElements(IList<RoutingHintLine> hintLines, IList<Vector3> splitPoints)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<RoutingHintLine> | hintLines | List of hint lines. |
System.Collections.Generic.IList<Vector3> | splitPoints | List of split points to visualize |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<Element> | List of graphics elements |
SetWeightModifiersGroupAggregator(String, Func<Double, Double, Double>)
Set factor aggregator function for weight modifiers group. The aggregator function will be applied to any list of weight modifications that share a group name. This ensures that if a type of modifier is applied to a single edge more than once we have options for how to apply duplicate modifiers. AggregateFactorMin(Double, Double) AggregateFactorMax(Double, Double) AggregateFactorMultiply(Double, Double)
Declaration
public void SetWeightModifiersGroupAggregator(string groupName, Func<double, double, double> groupFactorAggregator)
Parameters
Type | Name | Description |
---|---|---|
System.String | groupName | Group name. |
System.Func<System.Double, System.Double, System.Double> | groupFactorAggregator | Factor aggregator function. |
ShortestBranchesDijkstra(UInt64, Dictionary<UInt64, EdgeInfo>, out Dictionary<UInt64, (Double, Double)>, Nullable<UInt64>, HashSet<UInt64>)
This is a Dijkstra algorithm implementation that stores up to two different paths per vertex. The algorithm travels from start point to all other points, gathering travel cost. Each time route turns - extra penalty is added to the cost. Higher level algorithm then decides which one of them to use as an end point. Produced dictionary has "Left/Right" label using which two best routes per vertex can be retried.
Declaration
public Dictionary<ulong, ((ulong, BranchSide), (ulong, BranchSide))> ShortestBranchesDijkstra(ulong start, Dictionary<ulong, EdgeInfo> edgeInfos, out Dictionary<ulong, (double, double)> travelCost, ulong? startDirection = null, HashSet<ulong> excluded = null)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | start | Start Vertex |
System.Collections.Generic.Dictionary<System.UInt64, EdgeInfo> | edgeInfos | Dictionary of Edge Id to precomputed information about it |
System.Collections.Generic.Dictionary<System.UInt64, System.ValueTuple<System.Double, System.Double>> | travelCost | Output dictionary where traveling costs are stored per Vertex for two possible branches |
System.Nullable<System.UInt64> | startDirection | Previous Vertex, if start Vertex is already part of the Route |
System.Collections.Generic.HashSet<System.UInt64> | excluded | Vertices that are not allowed to visit |
Returns
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.UInt64, System.ValueTuple<System.ValueTuple<System.UInt64, BranchSide>, System.ValueTuple<System.UInt64, BranchSide>>> | Dictionary that have two travel routes from each Vertex back to start Vertex. |
ShortestPathDijkstra(UInt64, Dictionary<UInt64, EdgeInfo>, out Dictionary<UInt64, Double>, Nullable<UInt64>, HashSet<UInt64>, Dictionary<UInt64, Nullable<UInt64>>)
This is a Dijkstra algorithm implementation. The algorithm travels from start point to all other points, gathering travel cost. Each time route turns - extra penalty is added to the cost. Higher level algorithm then decides which one of them to use as an end point.
Declaration
public Dictionary<ulong, ulong> ShortestPathDijkstra(ulong start, Dictionary<ulong, EdgeInfo> edgeInfos, out Dictionary<ulong, double> travelCost, ulong? startDirection = null, HashSet<ulong> excluded = null, Dictionary<ulong, ulong?> pathDirections = null)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | start | Start Vertex |
System.Collections.Generic.Dictionary<System.UInt64, EdgeInfo> | edgeInfos | Dictionary of Edge Id to precomputed information about it |
System.Collections.Generic.Dictionary<System.UInt64, System.Double> | travelCost | Output dictionary where traveling cost is stored per Vertex |
System.Nullable<System.UInt64> | startDirection | Previous Vertex, if start Vertex is already part of the Route |
System.Collections.Generic.HashSet<System.UInt64> | excluded | Vertices that are not allowed to visit |
System.Collections.Generic.Dictionary<System.UInt64, System.Nullable<System.UInt64>> | pathDirections | Next Vertex dictionary for Vertices that are already part of the route |
Returns
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.UInt64, System.UInt64> | Dictionary that have travel routes from each Vertex back to start Vertex. |