PHPackages                             leonard/route-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. leonard/route-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

leonard/route-generator
=======================

Generates the route with highest success chance from the given tickets

01PHP

Since Aug 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/lessan98/route-generator)[ Packagist](https://packagist.org/packages/leonard/route-generator)[ RSS](/packages/leonard-route-generator/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Getting Started
---------------

[](#getting-started)

Basic idea is to generate an oriented graph from the tickets location and destinations and add arcs based on the direction. After that, we use a depth first search algorithm to find the terminal node and determine the fastest route there. In case there are more terminal nodes, the program will throw an error.

Note that even if there are no different classes for different ticket types, te time was mostly spent on trying to optimise the algorithm and suggesting an optimal route. Also, there were performed only manual tests.

There were more assumptions made here:

- Kevin's family will have the same tickets as Kevin
- Kevin's family WILL use ALL of the tickets, but Kevin doesn't have to
- There is no problem if Kevin reaches a location before his family, it is actually preffered this way, since they have a head start, he will wait for them there (since there is no travel time added on the tickets, he will wait for them at the final location.)
- There might be locations with multiple tickets. In case that is not the end of the journey, we need to ensure there is an alternate route to go back from there, otherwise kevin will be in a situation where he will need to choose the final location from multiple choices that could be suitable for this role. [![](https://camo.githubusercontent.com/1668bd8d1f1860ebf348eddc8ca8bcd9a86e8feff7b06c1da14acd4cb4207e95/68747470733a2f2f7374617469632e6a61766174706f696e742e636f6d2f64732f696d616765732f62696e6172792d747265652e706e67)](https://camo.githubusercontent.com/1668bd8d1f1860ebf348eddc8ca8bcd9a86e8feff7b06c1da14acd4cb4207e95/68747470733a2f2f7374617469632e6a61766174706f696e742e636f6d2f64732f696d616765732f62696e6172792d747265652e706e67)
     Take the above case for example, if the would be the generated route using the tickets, kevin will don't know if the ending location should be the 3,5 or 6 node, hence an error will be thrown.

### Prerequisites

[](#prerequisites)

You can either install it :

- with composer ```
    composer require test/route-generator
    ```
- or clone this repo and run the following command in the root directory of the project ```
    composer dump-autoload
    ```

Usage
-----

[](#usage)

```
use Test\RouteGenerator\RouteGenerator;
use Test\RouteGenerator\Ticket;
use Test\RouteGenerator\TicketType;

 $routerGenerator = new RouteGenerator([
   new Ticket('Germany', 'Italy', TicketType::Boat, 'RJ 45', 'Seat 32'),
   new Ticket('Germany', 'France', TicketType::Bus, '336'),
   new Ticket('Italy', 'Spain', TicketType::Airplane, 'ITSP 453'),
   new Ticket('Spain', 'Austria', TicketType::Bus, '', 'No seats'),
   new Ticket('France', 'Portugal', TicketType::Boat),
   new Ticket('Portugal', 'France', TicketType::Airplane),
   new Ticket('France', 'Bulgaria', TicketType::Boat),
   new Ticket('Bulgaria', 'France', TicketType::Bus),
   new Ticket('France', 'Romania', TicketType::Airplane),
   new Ticket('Romania', 'Greece', TicketType::Train),
   new Ticket('Greece', 'Germany', TicketType::Bus),
], 'Germany');

foreach($routerGenerator->getRoute() as $ticket){
   echo $ticket;
}
```

Possible improvements
---------------------

[](#possible-improvements)

Some possible improvements for this could be, when the algorithm gets confused, instead of throwing an error, give Kevin the option to manually choose the next step.

Adding the travel time on the ticket, that way it would be much more accurate to approximate the meeting spot.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/635205f3747aa146f90269d6fda52d953c06b6042f179ce4d24fcfc06ba01412?d=identicon)[lessan98](/maintainers/lessan98)

---

Top Contributors

[![lessan98](https://avatars.githubusercontent.com/u/32074479?v=4)](https://github.com/lessan98 "lessan98 (2 commits)")

### Embed Badge

![Health badge](/badges/leonard-route-generator/health.svg)

```
[![Health](https://phpackages.com/badges/leonard-route-generator/health.svg)](https://phpackages.com/packages/leonard-route-generator)
```

###  Alternatives

[prooph/php-cs-fixer-config

PHP CS Fixer config for prooph components

2474.8k65](/packages/prooph-php-cs-fixer-config)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
