Search
PathFinder.generateShortestRoute Method
See Also
 





Calculates a route that passes through all nodes of the diagram. This implementation of the Traveling Salesperson Problem uses the nearest-neighbor heuristic.

Namespace: MindFusion.Diagramming
Assembly: PathFinder.js

 Syntax

JavaScript  Copy Code

function generateShortestRoute ([weight])

 Parameters

weight
Optional.

function. A function that takes two DiagramNode arguments and returns a number that represents the distance between them. If not provided, the geometric distance between the nodes' centers is used.

 Return Value

A Path object with its nodes and items fields populated, representing approximate shortest route found by the heuristic.

 Remarks

This method does not consider current links in the diagram. Instead, it uses geometrical distance between nodes or the result of weight function to suggest the sequence of nodes you should connect to generate approximate shortest path passing between them.

 See Also