question

Weilin L2 avatar image
0 Likes"
Weilin L2 asked Phil BoBo commented

Which path to take between two points on a network?

The default option for an operator is to take the shortest path between two points on a network. But if there are multiple paths having the same distance between two points (e.g., a grid network with equal distance between adjacent nodes), what’s the secondary logic to decide which path to take?

network nodespath networkpathfinding
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
0 Likes"
Phil BoBo answered Phil BoBo commented

The Network Navigator uses Dijkstra's algorithm to calculate the shortest path from each node to each other node. The first shortest valid path it finds from a node to another node will be the path it takes.

In the case of two paths that are the same distance from one node to another, it will use whichever one it found first. The order you created the nodes and the order that you connected the nodes will affect which path is found first.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Weilin L2 avatar image Weilin L2 commented ·

Thank you for your explanation. Is there a way to find the path with minimum number of turns among all the same shortest distance paths?

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Weilin L2 commented ·

The behavior of the Network Navigator is compiled into the object in the library: MAIN:/project/library/NetworkNavigator>behaviour/cppfunctions/generateDistanceTable()

To change the behavior of how it works, you would need to subclass that object using the Module Development SDK and then override the functions that you want to change. That is not an easy task and is probably overkill for what you are trying to do.

An easier way would probably be to determine the path you want to take yourself and then break up your travel task into multiple tasks that go to the particular nodes you want to go to in the order you want to go.

2 Likes 2 ·