0.0.3 • Published 1 year ago

leonetti-graph-search v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Graph Search implemented on 2D matrix using TypeScript.

graph search implemented on 2D matrix using TypeScript.

Install

npm install @leonetti/graph-search

Usage

import {mazeSearch} from '@leonetti/graph-search';


/* define the maze */

const maze = [
        [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 1, 1, 0, 1, 1, 1, 1, 1, 0],
        [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
        [0, 1, 1, 1, 1, 0, 1, 1, 1, 1],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 1, 1, 0, 1, 1, 1, 1, 1, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
];

/* define start and end points row column */
const start = { x: 0, y: 0 };
const end = { x: 9, y: 9 };

mazeSearch(maze, start, end);
0.0.3

1 year ago