A Graph Library Implementing Multiple Algorithms and Graph Capabalities
This library contains Algorithms such as:
- Prims MST Algorithm
- Kruskals MST Algorithm
- Depth First Search
- Breadth First Search
- Dijkstras Algorithm
- Find a Path using Backtracking (DFS style)
Along with this - You can Add Vertices and Edges between the Vertices in an Adjacency List Format. TypeScript was used for this project to keep functions and algorithms in the graph strongly typed, preventing any mistakes with inputs.
To test the program, you will need to have Jest installed, which is a testing library commonly used for Web development (React, Next.JS) Rather than using the graph library in a regular .js file. I wrote the tests in Jest as this is a more common, professional way to test functionality, and it also comes with a lot of great utilities that make writing tests easy.
10 Tests can be ran on the graph library, and the .test.ts file can be edited further for the sake of testing. These tests show the functionality of the MST functions, as well as BFS and DFS, Dijkstra as well.
- GraphLibTest.test.ts
- Is a file that uses jests testing framework on the GraphLibrary Class that is implemented in GraphLibrary.ts
- You will run this file, in doing so the tests will appear that check the functionality of the GraphLibrary
- Desktop, or Laptop Device
- Node Version 16.0.0 or Later
- Terminal / Visual Studio Code Editor Terminal
Before running you will need to install a few things:
Important
Double check that you have TypeScript and Jest downloaded. (To run the .test.ts file you will need Jest downloaded globally, so use the -g accordingly which can be seen below.) Open a Terminal, within the source code directory on your computer - Run the following commands.
- npm install -g typescript
- npm install --save-dev ts-jest @types/jest
- npm i -g jest
To Run the project, download the source folder from the repository, and place it in any given directory of your choosing. Navigate to the directory where the source folder is, and cd into the source code folder. Once Jest is downloaded, to run the test file, simply run:
- jest --watch
This will run the test suite and you will be able to see that all tests pass with the algorithms that are used.