Skip to main content




VRP or Vehicle Routing problem is a generalization of the Travelling Salesman Problem. The goal of the problem is to find the shortest route that visits each node once, starting and finishing from the same node, called a depot, while using a fleet of vehicles. Each vehicle does not need to be at every location, it is enough that every node is visited by at least one vehicle. The problem is NP-hard in optimization, and therefore methods such as constraint programming, approximations or heuristics are a good approach for solving. The current implementation of VRP includes constraint programming with GEKKO solver which works with 1 depot and an arbitrary number of vehicles. The algorithm uses the distance calculator to determine the distance between driving points, and works only with geographical locations, meaning each node needs to have its lat and lng property.

(location:Location {lat: 44.1194, lng: 15.2314})
Module typemodule
Graph directionundirected
Edge weightsunweighted



If you want to execute this algorithm on graph projections, subgraphs or portions of the graph, be sure to check out the guide on How to run a MAGE module on subgraphs.

route(depot_node, number_of_vehicles)


  • depot_node: Vertex ➡ Depot node with its corresponding lat and lng coordinate properties.
  • number_of_vehicles: integer = 1 ➡ Designates how many vehicles are used. Set to 1 by default


  • from_vertex: Vertex ➡ Beginning point of one part of the route
  • to_vertex: Vertex ➡ Ending point of one part of the route
  • vehicle_id: integer ➡ Vehicle ID that will drive the corresponding path (from_vertex)->(to_vertex) All pairs of the route represent the full route with all vehicles used.


MATCH (d:Depot)
CALL vrp.route(d) YIELD from_vertex, to_vertex, vehicle_id;