Updated on 2023-08-04 GMT+08:00

Shortest Path

Overview

The Shortest Path algorithm is used to find the shortest path between two nodes in a graph.

Application Scenarios

This algorithm applies to scenarios such as path design and network planning.

Parameter Description

Table 1 Shortest Paths algorithm parameters

Parameter

Mandatory

Description

Type

Value Range

Default Value

source

Yes

Enter the source ID of a path.

String

-

-

target

Yes

Enter the target ID of a path.

String

-

-

directed

No

Whether an edge is directed

Bool

true or false

false

weight

No

Weight of an edge

String

Empty or null character string

  • Empty: The default weight and distance are 1.
  • Character string: The attribute of the corresponding edge is the weight. When the edge does not have corresponding attribute, the weight is 1 by default.
    NOTE:

    The weight of an edge must be greater than 0.

-

timeWindow

No

Time window used for time filtering

Json

For details, see Table 2.

NOTE:

timeWindow does not support the shortest path with weight. That is, parameters timeWindow and weight cannot be both specified.

-

Table 2 timeWindow parameters

Parameter

Mandatory

Description

Type

Value Range

Default Value

filterName

Yes

Name of the time attribute used for time filtering

String

Character string: The attribute on the corresponding vertex/edge is used as the time.

-

filterType

No

Filtering by vertex or edge

String

V: Filtering by vertex

E: Filtering by edge

BOTH: Filtering by vertex and edge

BOTH

startTime

No

Start time

String

Date character string or timestamp

-

endTime

No

End time

String

Date character string or timestamp

-

Precautions

This algorithm only returns one shortest path.

Example

Calculate the shortest path from the Lee node to the Alice node.

Set parameters source to Lee, target to Alice, weight to weights, and directed to false. The shortest path is displayed on the canvas, and the JSON result is displayed in the result area.