This is a js practice for graph search algorithms, breadth-first search and depth-first search.
Clone this repo and take a look:
npm i && npm start
Sample data is a list of airports in Kenya:
NBO MSA NAK ELD KSM NYR NYK LOD MAL KIL KTL
Their hypothetical routes:
['NBO', 'MSA'],
['NBO','ELD'],
['NBO','KSM'],
['MSA', 'MAL'],
['MSA', 'KIL'],
['KSM', 'ELD'],
['KSM', 'KTL'],
['KTL', 'NYR'],
['NYK', 'NYR'],
['NYR', 'MSA'],
['KTL', 'LOD'],
['LOD', 'ELD'],
To create nodes, we append the airport short names to an empty map. Then, for each route, we fetch the origin from the mapped list and append the destination of the point index.