Skip to main content
Version: 0.13.0

Route tool

Introduced 0.13.0

The RouteTool, which an agent sees as FindRoute, finds a path between two nodes on an indexed network — roads, pipes, cables, corridors.

The cost is an integral field (long, integer, short, or byte) on the edges, so the same graph answers "shortest", "fastest", and "cheapest" depending on which field you pass. The answer names that field next to the total, so the unit stays the unit in your data. from and to are node ids already in the network. Build the graph with _graph/build before the first route (see the routing page).

When the graph has no path from from to to, the answer states that and repeats the nodes that were asked for.

Build the network first. See Road routing and network traversal.

Parameters

ParameterRequiredDescription
indexYesThe index holding the network.
fieldYesThe graph_edge field.
weight_fieldYesThe numeric field holding each edge's cost.
fromYesThe node id to start from.
toYesThe node id to reach.

Up to 50 nodes of the route are listed; longer routes are summarised.

Register a flow agent that runs the RouteTool

POST /_plugins/_agent/agents/_register
{
"name": "Routing_Agent",
"type": "flow",
"description": "finds a route on the road network",
"tools": [
{
"type": "RouteTool",
"name": "DemoFindRoute",
"parameters": {
"index": "roads",
"field": "road",
"weight_field": "seconds"
}
}
]
}
POST /_plugins/_ml/agents/<agent_id>/_execute
{
"parameters": { "from": "1001", "to": "4482" }
}