Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. A mother vertex is a vertex in a graph from which all other vertices can be reached by at least one path. There
2. A mother vertex is a vertex in a graph from which all other vertices can be reached by at least one path. There may be more than one mother vertex in a graph! Create a new Java class in a file called "Mothers.java" and define a static method named findMothers that declares parameters for an unweighted graph of strings and a complete list of the values in the graph. It should return a List of values. The signature of the function is therefore: public static List findMothers(Graph graph, List values) E A a. Implement an algorithm in findMothers for finding mother vertices in the graph using the list of values passed in as a parameter to the function. Return a list of the values representing all mother vertices in the graph and print them out. Hint 1: use the bfSearch method in your function. b. Define a main method and build the 2 graphs (of Strings) below to test your function. Hint 2: you can use Arrays.asList (...) to create an unmodifiable list from any number of parameters. For example: Arrays.asList ("a", "b", "c") will create a list containing the values "a", "b", and "c".. D B Mother Vertices: A, B, and E C X U Z T Y Mother Vertex: Z V W NOTE: it is not necessary to modify the starter code for this assignment. Write your own class, main method, and findMothers method for this question.
Step by Step Solution
★★★★★
3.37 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
import javautil class Graph public int v public HashMap graph public Graphint vertices thisv vertice...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started