Adds an edge :math:`(i, j)` between ``frm`` (:math:`i`) and ``to`` (:math:`j`). The edge can be given distance and duration attributes. Distance is required, but the default duration is zero. Returns the created edge. .. note:: If ``profile`` is
(
self,
frm: Client | Depot,
to: Client | Depot,
distance: int,
duration: int = 0,
profile: Profile | None = None,
)
| 312 | return depot |
| 313 | |
| 314 | def add_edge( |
| 315 | self, |
| 316 | frm: Client | Depot, |
| 317 | to: Client | Depot, |
| 318 | distance: int, |
| 319 | duration: int = 0, |
| 320 | profile: Profile | None = None, |
| 321 | ) -> Edge: |
| 322 | """ |
| 323 | Adds an edge :math:`(i, j)` between ``frm`` (:math:`i`) and ``to`` |
| 324 | (:math:`j`). The edge can be given distance and duration attributes. |
| 325 | Distance is required, but the default duration is zero. Returns the |
| 326 | created edge. |
| 327 | |
| 328 | .. note:: |
| 329 | |
| 330 | If ``profile`` is not provided, the edge is a base edge that will be |
| 331 | set for all profiles in the model. Any profile-specific edge takes |
| 332 | precedence over a base edge with the same ``frm`` and ``to`` |
| 333 | locations. |
| 334 | |
| 335 | .. note:: |
| 336 | |
| 337 | If called repeatedly with the same ``frm``, ``to``, and ``profile`` |
| 338 | arguments, only the edge constructed last is used. PyVRP does not |
| 339 | support multigraphs. |
| 340 | """ |
| 341 | if profile is not None: |
| 342 | return profile.add_edge(frm, to, distance, duration) |
| 343 | |
| 344 | edge = Edge(frm=frm, to=to, distance=distance, duration=duration) |
| 345 | self._edges.append(edge) |
| 346 | return edge |
| 347 | |
| 348 | def add_profile(self, *, name: str = "") -> Profile: |
| 349 | """ |