:

  1. Let .
  2. Let
  3. While :
    1. Let
    2. If :
      1. Let
    3. Else:
      1. Let
  4. Return route of length

:

  1. Use algorithm to find optimal route
  2. If length of :
    1. Return route
  3. Else:
    1. Return