PHP Classes


Recommend this page to a friend!
  Classes of Malik Naik   PHP Breadth First Search   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Breadth First Search
Find the shortest path to visit warehouse bins
Author: By
Last change:
Date: 5 months ago
Size: 1,539 bytes


Class file image Download

Sylvane Task

This is a task to find the shortest path by visiting all the bins in the warehouse and coming back to the start position in an optimal way.


  1. We are considering the aisle as the nodes in the graph and when we are at a certain aisle we can pick the item from the bin on either side of the aisle.
  2. The Modified Breadth-First Search is used to find the shortest path from all pairs of nodes in the graph.
  3. Starting with the start position this approach greedily picks the nearst node from the start position and then takes the path and then from there picks the next nearsest node until all the bins are visited.
  4. Finally, it returns back to the start position.

The graph of the warehouse is as follows: WareHouse Visualization

In the above graph, the green nodes are the aisles and are paths that can be traversed and the white nodes are the bins from which we can pick the items.


To test the working of this code. Clone this repository and then run the following command:

php main.php

Make sure you have PHP CLI installed before running the above command.


To execute the visualization using Python you need to install the NetworkX and Matplotlib libraries. They can be installed by running the following command:

python -m pip install -r requirements.txt

Then, run the following command to generate the visualization of the Warehouse.