Question: Need a simple exercise with a graph based on an adjacency list. provide two method implementations for the following class: import java . util .
Need a simple exercise with a graph based on an adjacency list. provide two method implementations for the following class:
import java . util . Map ; import java . util . Set ; import java . util . List ; public class Graph
the following methods are needed: 1. void addEdge(T start, T end) This code adds the directed edge (start, end) to the graph. In the map adjacency, get or create the Set associated with start, and add end to this Set. 2. boolean testPath(List vertexList) This method should return true if each consecutive pair of vertices in the list exists in the graph, false otherwise. Throw an exception if vertexList doesnt have at least one edges worth of vertices in it!
Here is a SAMPLE

here is the output to the sample

public static void main (String[] args) Graph
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
