Respond to short response questions in clear, concise sentences directly within this file. Use markdown to ensure that your answers are formatted correctly.
Complete code challenges in exercises.js.
Use Test Driven Development to guide you. Run npm install to download dependencies. Run npm test to run tests locally. Ensure all tests are passing before submitting this problem set.
1. What are the properties of a graph?
2. What types of problems do graphs help us solve? What are some of the limitations?
3. What is the difference between breadth-first and depth-first search? When might you choose one over the other?
-
Implement a Graph Class: Implement a graph class. Your class should respond to the following methods:
getVertexaddVertexremoveVertexaddEdgeremoveEdge
-
Breadth-First Search: Implement a
breadthFirstSearchfunction that takes in a graph, a start vertex, and an end vertex to search for, and locates the given vertex using a breadth-first search algorith. The function should returntrueif a path exists between the start and end vertices, and should returnfalseif no path exists. As a reminder, BFS algorithms should search along each level before proceeding further down the graph. -
Depth-First Search: Implement a
depthFirstSearchfunction that takes in a graph, a start vertex, and an end vertex to search for, and locates the given vertex using a depth-first search algorith. The function should returntrueif a path exists between the start and end vertices, and should returnfalseif no path exists. As a reminder, DFS algortihms should search down paths before moving on to child functions.